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/dev/dist/index.js CHANGED
@@ -245,7 +245,7 @@ function getCallerLocation() {
245
245
  }
246
246
 
247
247
  // src/logger.ts
248
- var _uuid = require('uuid');
248
+ var _uuid = require('uuid'); var uuid3 = _interopRequireWildcard(_uuid); var uuid2 = _interopRequireWildcard(_uuid); var uuid = _interopRequireWildcard(_uuid);
249
249
 
250
250
  // src/queue.ts
251
251
  var DEFAULT_QUEUE_SIZE = 15e3;
@@ -303,33 +303,1014 @@ var Queue = (_class = class {
303
303
  }
304
304
  }, _class);
305
305
 
306
- // src/logger.ts
306
+ // util/db_fields.ts
307
+ var TRANSACTION_ID_FIELD = "_xact_id";
308
+ var IS_MERGE_FIELD = "_is_merge";
309
+ var AUDIT_SOURCE_FIELD = "_audit_source";
310
+ var AUDIT_METADATA_FIELD = "_audit_metadata";
311
+ var VALID_SOURCES = ["app", "api", "external"];
312
+ var PARENT_ID_FIELD = "_parent_id";
307
313
 
314
+ // util/span_identifier_v3.ts
308
315
 
309
316
 
317
+ // util/span_identifier_v2.ts
310
318
 
311
319
 
320
+ // util/span_identifier_v1.ts
312
321
 
322
+ var _v3 = require('zod/v3');
323
+ function tryMakeUuid(s) {
324
+ try {
325
+ const ret = uuid.parse(s);
326
+ if (ret.length !== 16) {
327
+ throw new Error();
328
+ }
329
+ return { bytes: Buffer.from(ret), isUUID: true };
330
+ } catch (e) {
331
+ return { bytes: Buffer.from(s, "utf-8"), isUUID: false };
332
+ }
333
+ }
334
+ var ENCODING_VERSION_NUMBER = 1;
335
+ 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";
336
+ var SpanObjectTypeV1 = /* @__PURE__ */ ((SpanObjectTypeV12) => {
337
+ SpanObjectTypeV12[SpanObjectTypeV12["EXPERIMENT"] = 1] = "EXPERIMENT";
338
+ SpanObjectTypeV12[SpanObjectTypeV12["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
339
+ return SpanObjectTypeV12;
340
+ })(SpanObjectTypeV1 || {});
341
+ var SpanObjectTypeV1EnumSchema = _v3.z.nativeEnum(SpanObjectTypeV1);
342
+ var SpanRowIdsV1 = class {
343
+
344
+
345
+
346
+ constructor(args) {
347
+ this.rowId = args.rowId;
348
+ this.spanId = args.spanId;
349
+ this.rootSpanId = args.rootSpanId;
350
+ if (!this.rowId) {
351
+ throw new Error("rowId must be nonempty string");
352
+ }
353
+ if (!this.spanId) {
354
+ throw new Error("spanId must be nonempty string");
355
+ }
356
+ if (!this.rootSpanId) {
357
+ throw new Error("rootSpanId must be nonempty string");
358
+ }
359
+ }
360
+ toObject() {
361
+ return {
362
+ rowId: this.rowId,
363
+ spanId: this.spanId,
364
+ rootSpanId: this.rootSpanId
365
+ };
366
+ }
367
+ };
368
+ var SpanComponentsV1 = class _SpanComponentsV1 {
369
+
370
+
371
+
372
+ constructor(args) {
373
+ this.objectType = args.objectType;
374
+ this.objectId = args.objectId;
375
+ this.rowIds = args.rowIds;
376
+ }
377
+ toStr() {
378
+ const allBuffers = [];
379
+ const { bytes: rowIdBytes, isUUID: rowIdIsUUID } = this.rowIds ? tryMakeUuid(this.rowIds.rowId) : { bytes: Buffer.from(""), isUUID: false };
380
+ allBuffers.push(
381
+ Buffer.from([
382
+ ENCODING_VERSION_NUMBER,
383
+ this.objectType,
384
+ this.rowIds ? 1 : 0,
385
+ rowIdIsUUID ? 1 : 0
386
+ ])
387
+ );
388
+ const { bytes: objectIdBytes, isUUID: objectIdIsUUID } = tryMakeUuid(
389
+ this.objectId
390
+ );
391
+ if (!objectIdIsUUID) {
392
+ throw new Error("object_id component must be a valid UUID");
393
+ }
394
+ allBuffers.push(objectIdBytes);
395
+ if (this.rowIds) {
396
+ const { bytes: spanIdBytes, isUUID: spanIdIsUUID } = tryMakeUuid(
397
+ this.rowIds.spanId
398
+ );
399
+ if (!spanIdIsUUID) {
400
+ throw new Error("span_id component must be a valid UUID");
401
+ }
402
+ const { bytes: rootSpanIdBytes, isUUID: rootSpanIdIsUUID } = tryMakeUuid(
403
+ this.rowIds.rootSpanId
404
+ );
405
+ if (!rootSpanIdIsUUID) {
406
+ throw new Error("root_span_id component must be a valid UUID");
407
+ }
408
+ allBuffers.push(spanIdBytes, rootSpanIdBytes, rowIdBytes);
409
+ }
410
+ return Buffer.concat(allBuffers).toString("base64");
411
+ }
412
+ static fromStr(s) {
413
+ try {
414
+ const rawBytes = Buffer.from(s, "base64");
415
+ if (rawBytes[0] !== ENCODING_VERSION_NUMBER) {
416
+ throw new Error();
417
+ }
418
+ const objectType = SpanObjectTypeV1EnumSchema.parse(rawBytes[1]);
419
+ if (![0, 1].includes(rawBytes[2])) {
420
+ throw new Error();
421
+ }
422
+ if (![0, 1].includes(rawBytes[3])) {
423
+ throw new Error();
424
+ }
425
+ const hasRowId = rawBytes[2] == 1;
426
+ const rowIdIsUUID = rawBytes[3] == 1;
427
+ const objectId = uuid.stringify(rawBytes.subarray(4, 20));
428
+ const rowIds = (() => {
429
+ if (!hasRowId) {
430
+ return void 0;
431
+ }
432
+ const spanId = uuid.stringify(rawBytes.subarray(20, 36));
433
+ const rootSpanId = uuid.stringify(rawBytes.subarray(36, 52));
434
+ const rowId = rowIdIsUUID ? uuid.stringify(rawBytes.subarray(52)) : rawBytes.subarray(52).toString("utf-8");
435
+ return new SpanRowIdsV1({ rowId, spanId, rootSpanId });
436
+ })();
437
+ return new _SpanComponentsV1({ objectType, objectId, rowIds });
438
+ } catch (e) {
439
+ throw new Error(INVALID_ENCODING_ERRMSG);
440
+ }
441
+ }
442
+ objectIdFields() {
443
+ switch (this.objectType) {
444
+ case 1 /* EXPERIMENT */:
445
+ return { experiment_id: this.objectId };
446
+ case 2 /* PROJECT_LOGS */:
447
+ return { project_id: this.objectId, log_id: "g" };
448
+ default:
449
+ throw new Error("Impossible");
450
+ }
451
+ }
452
+ toObject() {
453
+ return {
454
+ objectType: this.objectType,
455
+ objectId: this.objectId,
456
+ rowIds: _optionalChain([this, 'access', _11 => _11.rowIds, 'optionalAccess', _12 => _12.toObject, 'call', _13 => _13()])
457
+ };
458
+ }
459
+ };
313
460
 
461
+ // util/span_identifier_v2.ts
314
462
 
463
+ function tryMakeUuid2(s) {
464
+ try {
465
+ const ret = uuid2.parse(s);
466
+ if (ret.length !== 16) {
467
+ throw new Error();
468
+ }
469
+ return { bytes: Buffer.from(ret), isUUID: true };
470
+ } catch (e) {
471
+ return { bytes: Buffer.from(s, "utf-8"), isUUID: false };
472
+ }
473
+ }
474
+ var ENCODING_VERSION_NUMBER2 = 2;
475
+ 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.`;
476
+ var INTEGER_ENCODING_NUM_BYTES = 4;
477
+ var SpanObjectTypeV2 = /* @__PURE__ */ ((SpanObjectTypeV22) => {
478
+ SpanObjectTypeV22[SpanObjectTypeV22["EXPERIMENT"] = 1] = "EXPERIMENT";
479
+ SpanObjectTypeV22[SpanObjectTypeV22["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
480
+ return SpanObjectTypeV22;
481
+ })(SpanObjectTypeV2 || {});
482
+ var SpanObjectTypeV2EnumSchema = _v3.z.nativeEnum(SpanObjectTypeV2);
483
+ var SpanRowIdsV2 = class {
484
+
485
+
486
+
487
+ constructor(args) {
488
+ this.rowId = args.rowId;
489
+ this.spanId = args.spanId;
490
+ this.rootSpanId = args.rootSpanId;
491
+ if (!this.rowId) {
492
+ throw new Error("rowId must be nonempty string");
493
+ }
494
+ if (!this.spanId) {
495
+ throw new Error("spanId must be nonempty string");
496
+ }
497
+ if (!this.rootSpanId) {
498
+ throw new Error("rootSpanId must be nonempty string");
499
+ }
500
+ }
501
+ toObject() {
502
+ return {
503
+ rowId: this.rowId,
504
+ spanId: this.spanId,
505
+ rootSpanId: this.rootSpanId
506
+ };
507
+ }
508
+ };
509
+ var SpanComponentsV2 = class _SpanComponentsV2 {
510
+
511
+
512
+
513
+
514
+ constructor(args) {
515
+ this.objectType = args.objectType;
516
+ this.objectId = args.objectId;
517
+ this.computeObjectMetadataArgs = args.computeObjectMetadataArgs;
518
+ this.rowIds = args.rowIds;
519
+ if (!(this.objectId || this.computeObjectMetadataArgs)) {
520
+ throw new Error(
521
+ "Must provide either objectId or computeObjectMetadataArgs"
522
+ );
523
+ }
524
+ }
525
+ toStr() {
526
+ const allBuffers = [];
527
+ const { bytes: rowIdBytes, isUUID: rowIdIsUUID } = this.rowIds ? tryMakeUuid2(this.rowIds.rowId) : { bytes: Buffer.from(""), isUUID: false };
528
+ allBuffers.push(
529
+ Buffer.from([
530
+ ENCODING_VERSION_NUMBER2,
531
+ this.objectType,
532
+ this.objectId ? 1 : 0,
533
+ this.computeObjectMetadataArgs ? 1 : 0,
534
+ this.rowIds ? 1 : 0,
535
+ rowIdIsUUID ? 1 : 0
536
+ ])
537
+ );
538
+ if (this.objectId) {
539
+ const { bytes: objectIdBytes, isUUID: objectIdIsUUID } = tryMakeUuid2(
540
+ this.objectId
541
+ );
542
+ if (!objectIdIsUUID) {
543
+ throw new Error("object_id component must be a valid UUID");
544
+ }
545
+ allBuffers.push(objectIdBytes);
546
+ }
547
+ if (this.computeObjectMetadataArgs) {
548
+ const computeObjectMetadataBytes = Buffer.from(
549
+ JSON.stringify(this.computeObjectMetadataArgs),
550
+ "utf-8"
551
+ );
552
+ const serializedLenBytes = Buffer.alloc(INTEGER_ENCODING_NUM_BYTES);
553
+ serializedLenBytes.writeInt32BE(computeObjectMetadataBytes.length);
554
+ allBuffers.push(serializedLenBytes, computeObjectMetadataBytes);
555
+ }
556
+ if (this.rowIds) {
557
+ const { bytes: spanIdBytes, isUUID: spanIdIsUUID } = tryMakeUuid2(
558
+ this.rowIds.spanId
559
+ );
560
+ if (!spanIdIsUUID) {
561
+ throw new Error("span_id component must be a valid UUID");
562
+ }
563
+ const { bytes: rootSpanIdBytes, isUUID: rootSpanIdIsUUID } = tryMakeUuid2(
564
+ this.rowIds.rootSpanId
565
+ );
566
+ if (!rootSpanIdIsUUID) {
567
+ throw new Error("root_span_id component must be a valid UUID");
568
+ }
569
+ allBuffers.push(spanIdBytes, rootSpanIdBytes, rowIdBytes);
570
+ }
571
+ return Buffer.concat(allBuffers).toString("base64");
572
+ }
573
+ static fromStr(s) {
574
+ try {
575
+ const rawBytes = Buffer.from(s, "base64");
576
+ if (rawBytes[0] < ENCODING_VERSION_NUMBER2) {
577
+ const spanComponentsOld = SpanComponentsV1.fromStr(s);
578
+ return new _SpanComponentsV2({
579
+ objectType: SpanObjectTypeV2EnumSchema.parse(
580
+ spanComponentsOld.objectType
581
+ ),
582
+ objectId: spanComponentsOld.objectId,
583
+ rowIds: spanComponentsOld.rowIds ? new SpanRowIdsV2({
584
+ rowId: spanComponentsOld.rowIds.rowId,
585
+ spanId: spanComponentsOld.rowIds.spanId,
586
+ rootSpanId: spanComponentsOld.rowIds.rootSpanId
587
+ }) : void 0
588
+ });
589
+ }
590
+ if (rawBytes[0] !== ENCODING_VERSION_NUMBER2) {
591
+ throw new Error();
592
+ }
593
+ const objectType = SpanObjectTypeV2EnumSchema.parse(rawBytes[1]);
594
+ for (let i = 2; i < 6; ++i) {
595
+ if (![0, 1].includes(rawBytes[i])) {
596
+ throw new Error();
597
+ }
598
+ }
599
+ const hasObjectId = rawBytes[2] == 1;
600
+ const hasComputeObjectMetadataArgs = rawBytes[3] == 1;
601
+ const hasRowId = rawBytes[4] == 1;
602
+ const rowIdIsUUID = rawBytes[5] == 1;
603
+ let byteCursor = 6;
604
+ let objectId = void 0;
605
+ if (hasObjectId) {
606
+ const nextByteCursor = byteCursor + 16;
607
+ objectId = uuid2.stringify(
608
+ rawBytes.subarray(byteCursor, nextByteCursor)
609
+ );
610
+ byteCursor = nextByteCursor;
611
+ }
612
+ let computeObjectMetadataArgs;
613
+ if (hasComputeObjectMetadataArgs) {
614
+ let nextByteCursor = byteCursor + INTEGER_ENCODING_NUM_BYTES;
615
+ const serializedLenBytes = rawBytes.readInt32BE(byteCursor);
616
+ byteCursor = nextByteCursor;
617
+ nextByteCursor = byteCursor + serializedLenBytes;
618
+ computeObjectMetadataArgs = JSON.parse(
619
+ rawBytes.subarray(byteCursor, nextByteCursor).toString("utf-8")
620
+ );
621
+ byteCursor = nextByteCursor;
622
+ }
623
+ const rowIds = (() => {
624
+ if (!hasRowId) {
625
+ return void 0;
626
+ }
627
+ let nextByteCursor = byteCursor + 16;
628
+ const spanId = uuid2.stringify(
629
+ rawBytes.subarray(byteCursor, nextByteCursor)
630
+ );
631
+ byteCursor = nextByteCursor;
632
+ nextByteCursor = byteCursor + 16;
633
+ const rootSpanId = uuid2.stringify(
634
+ rawBytes.subarray(byteCursor, nextByteCursor)
635
+ );
636
+ byteCursor = nextByteCursor;
637
+ const rowId = rowIdIsUUID ? uuid2.stringify(rawBytes.subarray(byteCursor)) : rawBytes.subarray(byteCursor).toString("utf-8");
638
+ return new SpanRowIdsV2({ rowId, spanId, rootSpanId });
639
+ })();
640
+ return new _SpanComponentsV2({
641
+ objectType,
642
+ objectId,
643
+ computeObjectMetadataArgs,
644
+ rowIds
645
+ });
646
+ } catch (e) {
647
+ throw new Error(INVALID_ENCODING_ERRMSG2);
648
+ }
649
+ }
650
+ objectIdFields() {
651
+ if (!this.objectId) {
652
+ throw new Error(
653
+ "Impossible: cannot invoke `object_id_fields` unless SpanComponentsV2 is initialized with an `object_id`"
654
+ );
655
+ }
656
+ switch (this.objectType) {
657
+ case 1 /* EXPERIMENT */:
658
+ return { experiment_id: this.objectId };
659
+ case 2 /* PROJECT_LOGS */:
660
+ return { project_id: this.objectId, log_id: "g" };
661
+ default:
662
+ throw new Error("Impossible");
663
+ }
664
+ }
665
+ toObject() {
666
+ return {
667
+ objectType: this.objectType,
668
+ objectId: this.objectId,
669
+ computeObjectMetadataArgs: this.computeObjectMetadataArgs,
670
+ rowIds: _optionalChain([this, 'access', _14 => _14.rowIds, 'optionalAccess', _15 => _15.toObject, 'call', _16 => _16()])
671
+ };
672
+ }
673
+ };
315
674
 
675
+ // util/span_identifier_v3.ts
316
676
 
317
677
 
678
+ // util/bytes.ts
679
+ function concatUint8Arrays(...arrays) {
680
+ const totalLength = arrays.reduce((acc, arr) => acc + arr.length, 0);
681
+ const result = new Uint8Array(totalLength);
682
+ let offset = 0;
683
+ for (const arr of arrays) {
684
+ result.set(arr, offset);
685
+ offset += arr.length;
686
+ }
687
+ return result;
688
+ }
689
+ function uint8ArrayToBase64(uint8Array) {
690
+ let binary = "";
691
+ for (let i = 0; i < uint8Array.length; i++) {
692
+ binary += String.fromCharCode(uint8Array[i]);
693
+ }
694
+ return btoa(binary);
695
+ }
696
+ function base64ToUint8Array(base64) {
697
+ const binary = atob(base64);
698
+ const uint8Array = new Uint8Array(binary.length);
699
+ for (let i = 0; i < binary.length; i++) {
700
+ uint8Array[i] = binary.charCodeAt(i);
701
+ }
702
+ return uint8Array;
703
+ }
704
+ function uint8ArrayToString(uint8Array) {
705
+ const decoder = new TextDecoder("utf-8");
706
+ return decoder.decode(uint8Array);
707
+ }
708
+ function stringToUint8Array(str) {
709
+ const encoder = new TextEncoder();
710
+ return encoder.encode(str);
711
+ }
318
712
 
713
+ // util/span_identifier_v3.ts
714
+ function tryMakeUuid3(s) {
715
+ try {
716
+ const ret = uuid3.parse(s);
717
+ if (ret.length !== 16) {
718
+ throw new Error();
719
+ }
720
+ return { bytes: new Uint8Array(ret), isUUID: true };
721
+ } catch (e3) {
722
+ return { bytes: void 0, isUUID: false };
723
+ }
724
+ }
725
+ var ENCODING_VERSION_NUMBER3 = 3;
726
+ 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.`;
727
+ var SpanObjectTypeV3 = /* @__PURE__ */ ((SpanObjectTypeV32) => {
728
+ SpanObjectTypeV32[SpanObjectTypeV32["EXPERIMENT"] = 1] = "EXPERIMENT";
729
+ SpanObjectTypeV32[SpanObjectTypeV32["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
730
+ SpanObjectTypeV32[SpanObjectTypeV32["PLAYGROUND_LOGS"] = 3] = "PLAYGROUND_LOGS";
731
+ return SpanObjectTypeV32;
732
+ })(SpanObjectTypeV3 || {});
733
+ var spanObjectTypeV3EnumSchema = _v3.z.nativeEnum(SpanObjectTypeV3);
734
+ function spanObjectTypeV3ToString(objectType) {
735
+ switch (objectType) {
736
+ case 1 /* EXPERIMENT */:
737
+ return "experiment";
738
+ case 2 /* PROJECT_LOGS */:
739
+ return "project_logs";
740
+ case 3 /* PLAYGROUND_LOGS */:
741
+ return "playground_logs";
742
+ default:
743
+ const x = objectType;
744
+ throw new Error(`Unknown SpanObjectTypeV3: ${x}`);
745
+ }
746
+ }
747
+ var InternalSpanComponentUUIDFields = /* @__PURE__ */ ((InternalSpanComponentUUIDFields2) => {
748
+ InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["OBJECT_ID"] = 1] = "OBJECT_ID";
749
+ InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["ROW_ID"] = 2] = "ROW_ID";
750
+ InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["SPAN_ID"] = 3] = "SPAN_ID";
751
+ InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["ROOT_SPAN_ID"] = 4] = "ROOT_SPAN_ID";
752
+ return InternalSpanComponentUUIDFields2;
753
+ })(InternalSpanComponentUUIDFields || {});
754
+ var internalSpanComponentUUIDFieldsEnumSchema = _v3.z.nativeEnum(
755
+ InternalSpanComponentUUIDFields
756
+ );
757
+ var _INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME = {
758
+ [1 /* OBJECT_ID */]: "object_id",
759
+ [2 /* ROW_ID */]: "row_id",
760
+ [3 /* SPAN_ID */]: "span_id",
761
+ [4 /* ROOT_SPAN_ID */]: "root_span_id"
762
+ };
763
+ var spanComponentsV3Schema = _v3.z.object({
764
+ object_type: spanObjectTypeV3EnumSchema,
765
+ // TODO(manu): We should have a more elaborate zod schema for
766
+ // `propagated_event`. This will required zod-ifying the contents of
767
+ // sdk/js/util/object.ts.
768
+ propagated_event: _v3.z.record(_v3.z.unknown()).nullish()
769
+ }).and(
770
+ _v3.z.union([
771
+ // Must provide one or the other.
772
+ _v3.z.object({
773
+ object_id: _v3.z.string().nullish(),
774
+ compute_object_metadata_args: _v3.z.optional(_v3.z.null())
775
+ }),
776
+ _v3.z.object({
777
+ object_id: _v3.z.optional(_v3.z.null()),
778
+ compute_object_metadata_args: _v3.z.record(_v3.z.unknown())
779
+ })
780
+ ])
781
+ ).and(
782
+ _v3.z.union([
783
+ // Either all of these must be provided or none.
784
+ _v3.z.object({
785
+ row_id: _v3.z.string(),
786
+ span_id: _v3.z.string(),
787
+ root_span_id: _v3.z.string()
788
+ }),
789
+ _v3.z.object({
790
+ row_id: _v3.z.optional(_v3.z.null()),
791
+ span_id: _v3.z.optional(_v3.z.null()),
792
+ root_span_id: _v3.z.optional(_v3.z.null())
793
+ })
794
+ ])
795
+ );
796
+ var SpanComponentsV3 = class _SpanComponentsV3 {
797
+ constructor(data) {
798
+ this.data = data;
799
+ }
800
+ toStr() {
801
+ const jsonObj = {
802
+ compute_object_metadata_args: this.data.compute_object_metadata_args || void 0,
803
+ propagated_event: this.data.propagated_event || void 0
804
+ };
805
+ const allBuffers = [];
806
+ allBuffers.push(
807
+ new Uint8Array([ENCODING_VERSION_NUMBER3, this.data.object_type])
808
+ );
809
+ const uuidEntries = [];
810
+ function addUuidField(origVal, fieldId) {
811
+ const ret = tryMakeUuid3(origVal);
812
+ if (ret.isUUID) {
813
+ uuidEntries.push(
814
+ concatUint8Arrays(new Uint8Array([fieldId]), ret.bytes)
815
+ );
816
+ } else {
817
+ jsonObj[_INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME[fieldId]] = origVal;
818
+ }
819
+ }
820
+ if (this.data.object_id) {
821
+ addUuidField(
822
+ this.data.object_id,
823
+ 1 /* OBJECT_ID */
824
+ );
825
+ }
826
+ if (this.data.row_id) {
827
+ addUuidField(this.data.row_id, 2 /* ROW_ID */);
828
+ }
829
+ if (this.data.span_id) {
830
+ addUuidField(this.data.span_id, 3 /* SPAN_ID */);
831
+ }
832
+ if (this.data.root_span_id) {
833
+ addUuidField(
834
+ this.data.root_span_id,
835
+ 4 /* ROOT_SPAN_ID */
836
+ );
837
+ }
838
+ if (uuidEntries.length > 255) {
839
+ throw new Error("Impossible: too many UUID entries to encode");
840
+ }
841
+ allBuffers.push(new Uint8Array([uuidEntries.length]));
842
+ allBuffers.push(...uuidEntries);
843
+ if (Object.keys(jsonObj).length > 0) {
844
+ allBuffers.push(stringToUint8Array(JSON.stringify(jsonObj)));
845
+ }
846
+ return uint8ArrayToBase64(concatUint8Arrays(...allBuffers));
847
+ }
848
+ static fromStr(s) {
849
+ try {
850
+ const rawBytes = base64ToUint8Array(s);
851
+ const jsonObj = {};
852
+ if (rawBytes[0] < ENCODING_VERSION_NUMBER3) {
853
+ const spanComponentsOld = SpanComponentsV2.fromStr(s);
854
+ jsonObj["object_type"] = spanComponentsOld.objectType;
855
+ jsonObj["object_id"] = spanComponentsOld.objectId;
856
+ jsonObj["compute_object_metadata_args"] = spanComponentsOld.computeObjectMetadataArgs;
857
+ if (spanComponentsOld.rowIds) {
858
+ jsonObj["row_id"] = spanComponentsOld.rowIds.rowId;
859
+ jsonObj["span_id"] = spanComponentsOld.rowIds.spanId;
860
+ jsonObj["root_span_id"] = spanComponentsOld.rowIds.rootSpanId;
861
+ }
862
+ } else {
863
+ jsonObj["object_type"] = rawBytes[1];
864
+ const numUuidEntries = rawBytes[2];
865
+ let byteOffset = 3;
866
+ for (let i = 0; i < numUuidEntries; ++i) {
867
+ const fieldId = internalSpanComponentUUIDFieldsEnumSchema.parse(
868
+ rawBytes[byteOffset]
869
+ );
870
+ const fieldBytes = rawBytes.subarray(byteOffset + 1, byteOffset + 17);
871
+ byteOffset += 17;
872
+ jsonObj[_INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME[fieldId]] = uuid3.stringify(fieldBytes);
873
+ }
874
+ if (byteOffset < rawBytes.length) {
875
+ const remainingJsonObj = JSON.parse(
876
+ uint8ArrayToString(rawBytes.subarray(byteOffset))
877
+ );
878
+ Object.assign(jsonObj, remainingJsonObj);
879
+ }
880
+ }
881
+ return _SpanComponentsV3.fromJsonObj(jsonObj);
882
+ } catch (e4) {
883
+ throw new Error(INVALID_ENCODING_ERRMSG3);
884
+ }
885
+ }
886
+ objectIdFields() {
887
+ if (!this.data.object_id) {
888
+ throw new Error(
889
+ "Impossible: cannot invoke `objectIdFields` unless SpanComponentsV3 is initialized with an `object_id`"
890
+ );
891
+ }
892
+ switch (this.data.object_type) {
893
+ case 1 /* EXPERIMENT */:
894
+ return { experiment_id: this.data.object_id };
895
+ case 2 /* PROJECT_LOGS */:
896
+ return { project_id: this.data.object_id, log_id: "g" };
897
+ case 3 /* PLAYGROUND_LOGS */:
898
+ return { prompt_session_id: this.data.object_id, log_id: "x" };
899
+ default:
900
+ const _ = this.data.object_type;
901
+ throw new Error("Impossible");
902
+ }
903
+ }
904
+ async export() {
905
+ return this.toStr();
906
+ }
907
+ static fromJsonObj(jsonObj) {
908
+ return new _SpanComponentsV3(spanComponentsV3Schema.parse(jsonObj));
909
+ }
910
+ };
911
+ function parseParent(parent) {
912
+ return typeof parent === "string" ? parent : parent ? new SpanComponentsV3({
913
+ object_type: parent.object_type === "experiment" ? 1 /* EXPERIMENT */ : parent.object_type === "playground_logs" ? 3 /* PLAYGROUND_LOGS */ : 2 /* PROJECT_LOGS */,
914
+ object_id: parent.object_id,
915
+ ...parent.row_ids ? {
916
+ row_id: parent.row_ids.id,
917
+ span_id: parent.row_ids.span_id,
918
+ root_span_id: parent.row_ids.root_span_id
919
+ } : {
920
+ row_id: void 0,
921
+ span_id: void 0,
922
+ root_span_id: void 0
923
+ },
924
+ propagated_event: parent.propagated_event
925
+ }).toStr() : void 0;
926
+ }
319
927
 
928
+ // util/http_headers.ts
929
+ var BT_FOUND_EXISTING_HEADER = "x-bt-found-existing";
930
+ var BT_CURSOR_HEADER = "x-bt-cursor";
320
931
 
932
+ // util/type_util.ts
933
+ function isObject(value) {
934
+ return value instanceof Object && !(value instanceof Array);
935
+ }
936
+ function isArray(value) {
937
+ return value instanceof Array;
938
+ }
939
+ function isObjectOrArray(value) {
940
+ return value instanceof Object;
941
+ }
321
942
 
943
+ // util/object_util.ts
944
+ function mergeDictsWithPaths({
945
+ mergeInto,
946
+ mergeFrom,
947
+ mergePaths
948
+ }) {
949
+ const mergePathsSerialized = new Set(
950
+ mergePaths.map((p) => JSON.stringify(p))
951
+ );
952
+ return mergeDictsWithPathsHelper({
953
+ mergeInto,
954
+ mergeFrom,
955
+ path: [],
956
+ mergePaths: mergePathsSerialized
957
+ });
958
+ }
959
+ function mergeDictsWithPathsHelper({
960
+ mergeInto,
961
+ mergeFrom,
962
+ path: path3,
963
+ mergePaths
964
+ }) {
965
+ Object.entries(mergeFrom).forEach(([k, mergeFromV]) => {
966
+ const fullPath = path3.concat([k]);
967
+ const fullPathSerialized = JSON.stringify(fullPath);
968
+ const mergeIntoV = recordFind(mergeInto, k);
969
+ if (isObject(mergeIntoV) && isObject(mergeFromV) && !mergePaths.has(fullPathSerialized)) {
970
+ mergeDictsWithPathsHelper({
971
+ mergeInto: mergeIntoV,
972
+ mergeFrom: mergeFromV,
973
+ path: fullPath,
974
+ mergePaths
975
+ });
976
+ } else {
977
+ mergeInto[k] = mergeFromV;
978
+ }
979
+ });
980
+ return mergeInto;
981
+ }
982
+ function mergeDicts(mergeInto, mergeFrom) {
983
+ return mergeDictsWithPaths({ mergeInto, mergeFrom, mergePaths: [] });
984
+ }
985
+ function mapAt(m, k) {
986
+ const ret = m.get(k);
987
+ if (ret === void 0) {
988
+ throw new Error(`Map does not contain key ${k}`);
989
+ }
990
+ return ret;
991
+ }
992
+ function recordFind(m, k) {
993
+ return m[k];
994
+ }
995
+ function getObjValueByPath(row, path3) {
996
+ let curr = row;
997
+ for (const p of path3) {
998
+ if (!isObjectOrArray(curr)) {
999
+ return null;
1000
+ }
1001
+ curr = curr[p];
1002
+ }
1003
+ return curr;
1004
+ }
322
1005
 
1006
+ // util/graph_util.ts
1007
+ function depthFirstSearch(args) {
1008
+ const { graph, firstVisitF, lastVisitF } = args;
1009
+ for (const vs of graph.values()) {
1010
+ for (const v of vs.values()) {
1011
+ if (!graph.has(v)) {
1012
+ throw new Error(`Outgoing vertex ${v} must be a key in the graph`);
1013
+ }
1014
+ }
1015
+ }
1016
+ const firstVisitedVertices = /* @__PURE__ */ new Set();
1017
+ const visitationOrder = _nullishCoalesce(args.visitationOrder, () => ( [...graph.keys()]));
1018
+ const events = visitationOrder.map((vertex) => ({ eventType: "first", vertex, extras: {} })).reverse();
1019
+ while (events.length) {
1020
+ const { eventType, vertex, extras } = events.pop();
1021
+ if (eventType === "last") {
1022
+ _optionalChain([lastVisitF, 'optionalCall', _17 => _17(vertex)]);
1023
+ continue;
1024
+ }
1025
+ if (firstVisitedVertices.has(vertex)) {
1026
+ continue;
1027
+ }
1028
+ firstVisitedVertices.add(vertex);
1029
+ _optionalChain([firstVisitF, 'optionalCall', _18 => _18(vertex, { parentVertex: extras.parentVertex })]);
1030
+ events.push({ eventType: "last", vertex, extras: {} });
1031
+ mapAt(graph, vertex).forEach((child) => {
1032
+ events.push({
1033
+ eventType: "first",
1034
+ vertex: child,
1035
+ extras: { parentVertex: vertex }
1036
+ });
1037
+ });
1038
+ }
1039
+ }
1040
+ function undirectedConnectedComponents(graph) {
1041
+ const directedGraph = new Map(
1042
+ [...graph.vertices].map((v) => [v, /* @__PURE__ */ new Set()])
1043
+ );
1044
+ for (const [i, j] of graph.edges) {
1045
+ mapAt(directedGraph, i).add(j);
1046
+ mapAt(directedGraph, j).add(i);
1047
+ }
1048
+ let labelCounter = 0;
1049
+ const vertexLabels = /* @__PURE__ */ new Map();
1050
+ const firstVisitF = (vertex, args) => {
1051
+ const label = _optionalChain([args, 'optionalAccess', _19 => _19.parentVertex]) !== void 0 ? mapAt(vertexLabels, _optionalChain([args, 'optionalAccess', _20 => _20.parentVertex])) : labelCounter++;
1052
+ vertexLabels.set(vertex, label);
1053
+ };
1054
+ depthFirstSearch({ graph: directedGraph, firstVisitF });
1055
+ const output = Array.from({ length: labelCounter }).map(() => []);
1056
+ for (const [vertex, label] of vertexLabels.entries()) {
1057
+ output[label].push(vertex);
1058
+ }
1059
+ return output;
1060
+ }
1061
+ function topologicalSort(graph, visitationOrder) {
1062
+ const reverseOrdering = [];
1063
+ const lastVisitF = (vertex) => {
1064
+ reverseOrdering.push(vertex);
1065
+ };
1066
+ depthFirstSearch({ graph, lastVisitF, visitationOrder });
1067
+ return reverseOrdering.reverse();
1068
+ }
323
1069
 
1070
+ // util/merge_row_batch.ts
1071
+ function generateMergedRowKey(row, useParentIdForId) {
1072
+ return JSON.stringify(
1073
+ [
1074
+ "org_id",
1075
+ "project_id",
1076
+ "experiment_id",
1077
+ "dataset_id",
1078
+ "prompt_session_id",
1079
+ "log_id",
1080
+ _nullishCoalesce(useParentIdForId, () => ( false)) ? PARENT_ID_FIELD : "id"
1081
+ ].map((k) => row[k])
1082
+ );
1083
+ }
1084
+ var MERGE_ROW_SKIP_FIELDS = [
1085
+ "created",
1086
+ "span_id",
1087
+ "root_span_id",
1088
+ "span_parents",
1089
+ "_parent_id"
1090
+ // TODO: handle merge paths.
1091
+ ];
1092
+ function popMergeRowSkipFields(row) {
1093
+ const popped = {};
1094
+ for (const field of MERGE_ROW_SKIP_FIELDS) {
1095
+ if (field in row) {
1096
+ popped[field] = row[field];
1097
+ delete row[field];
1098
+ }
1099
+ }
1100
+ return popped;
1101
+ }
1102
+ function restoreMergeRowSkipFields(row, skipFields) {
1103
+ for (const field of MERGE_ROW_SKIP_FIELDS) {
1104
+ delete row[field];
1105
+ if (field in skipFields) {
1106
+ row[field] = skipFields[field];
1107
+ }
1108
+ }
1109
+ }
1110
+ function mergeRowBatch(rows) {
1111
+ for (const row of rows) {
1112
+ if (row.id === void 0) {
1113
+ throw new Error(
1114
+ "Logged row is missing an id. This is an internal braintrust error. Please contact us at info@braintrust.dev for help"
1115
+ );
1116
+ }
1117
+ }
1118
+ const rowGroups = /* @__PURE__ */ new Map();
1119
+ for (const row of rows) {
1120
+ const key = generateMergedRowKey(row);
1121
+ const existingRow = rowGroups.get(key);
1122
+ if (existingRow !== void 0 && row[IS_MERGE_FIELD]) {
1123
+ const skipFields = popMergeRowSkipFields(existingRow);
1124
+ const preserveNoMerge = !existingRow[IS_MERGE_FIELD];
1125
+ mergeDicts(existingRow, row);
1126
+ restoreMergeRowSkipFields(existingRow, skipFields);
1127
+ if (preserveNoMerge) {
1128
+ delete existingRow[IS_MERGE_FIELD];
1129
+ }
1130
+ } else {
1131
+ rowGroups.set(key, row);
1132
+ }
1133
+ }
1134
+ const merged = [...rowGroups.values()];
1135
+ const rowToLabel = new Map(
1136
+ merged.map((r, i) => [generateMergedRowKey(r), i])
1137
+ );
1138
+ const graph = new Map(
1139
+ Array.from({ length: merged.length }).map((_, i) => [i, /* @__PURE__ */ new Set()])
1140
+ );
1141
+ merged.forEach((r, i) => {
1142
+ const parentId = r[PARENT_ID_FIELD];
1143
+ if (!parentId) {
1144
+ return;
1145
+ }
1146
+ const parentRowKey = generateMergedRowKey(
1147
+ r,
1148
+ true
1149
+ /* useParentIdForId */
1150
+ );
1151
+ const parentLabel = rowToLabel.get(parentRowKey);
1152
+ if (parentLabel !== void 0) {
1153
+ mapAt(graph, parentLabel).add(i);
1154
+ }
1155
+ });
1156
+ const connectedComponents = undirectedConnectedComponents({
1157
+ vertices: new Set(graph.keys()),
1158
+ edges: new Set(
1159
+ [...graph.entries()].flatMap(
1160
+ ([k, vs]) => [...vs].map((v) => {
1161
+ const ret = [k, v];
1162
+ return ret;
1163
+ })
1164
+ )
1165
+ )
1166
+ });
1167
+ const buckets = connectedComponents.map(
1168
+ (cc) => topologicalSort(
1169
+ graph,
1170
+ cc
1171
+ /* visitationOrder */
1172
+ )
1173
+ );
1174
+ return buckets.map((bucket) => bucket.map((i) => merged[i]));
1175
+ }
1176
+ function batchItems(args) {
1177
+ let { items } = args;
1178
+ const batchMaxNumItems = _nullishCoalesce(args.batchMaxNumItems, () => ( Number.POSITIVE_INFINITY));
1179
+ const batchMaxNumBytes = _nullishCoalesce(args.batchMaxNumBytes, () => ( Number.POSITIVE_INFINITY));
1180
+ const output = [];
1181
+ let nextItems = [];
1182
+ let batchSet = [];
1183
+ let batch = [];
1184
+ let batchLen = 0;
1185
+ function addToBatch(item) {
1186
+ batch.push(item);
1187
+ batchLen += item.length;
1188
+ }
1189
+ function flushBatch() {
1190
+ batchSet.push(batch);
1191
+ batch = [];
1192
+ batchLen = 0;
1193
+ }
1194
+ while (items.length) {
1195
+ for (const bucket of items) {
1196
+ let i = 0;
1197
+ for (const item of bucket) {
1198
+ if (batch.length === 0 || item.length + batchLen < batchMaxNumBytes && batch.length < batchMaxNumItems) {
1199
+ addToBatch(item);
1200
+ } else if (i === 0) {
1201
+ flushBatch();
1202
+ addToBatch(item);
1203
+ } else {
1204
+ break;
1205
+ }
1206
+ ++i;
1207
+ }
1208
+ if (i < bucket.length) {
1209
+ nextItems.push(bucket.slice(i));
1210
+ }
1211
+ if (batchLen >= batchMaxNumBytes || batch.length > batchMaxNumItems) {
1212
+ flushBatch();
1213
+ }
1214
+ }
1215
+ if (batch.length) {
1216
+ flushBatch();
1217
+ }
1218
+ if (batchSet.length) {
1219
+ output.push(batchSet);
1220
+ batchSet = [];
1221
+ }
1222
+ items = nextItems;
1223
+ nextItems = [];
1224
+ }
1225
+ return output;
1226
+ }
1227
+
1228
+ // util/object.ts
1229
+ var DEFAULT_IS_LEGACY_DATASET = false;
1230
+ function ensureDatasetRecord(r, legacy) {
1231
+ if (legacy) {
1232
+ return ensureLegacyDatasetRecord(r);
1233
+ } else {
1234
+ return ensureNewDatasetRecord(r);
1235
+ }
1236
+ }
1237
+ function ensureLegacyDatasetRecord(r) {
1238
+ if ("output" in r) {
1239
+ return r;
1240
+ }
1241
+ const row = {
1242
+ ...r,
1243
+ output: r.expected
1244
+ };
1245
+ delete row.expected;
1246
+ return row;
1247
+ }
1248
+ function ensureNewDatasetRecord(r) {
1249
+ if ("expected" in r) {
1250
+ return r;
1251
+ }
1252
+ const row = {
1253
+ ...r,
1254
+ tags: null,
1255
+ expected: r.output
1256
+ };
1257
+ delete row.output;
1258
+ return row;
1259
+ }
1260
+
1261
+ // util/json_util.ts
1262
+ function constructJsonArray(items) {
1263
+ return `[${items.join(",")}]`;
1264
+ }
1265
+
1266
+ // util/string_util.ts
1267
+ function _urljoin(...parts) {
1268
+ return parts.map(
1269
+ (x, i) => x.replace(/^\//, "").replace(i < parts.length - 1 ? /\/$/ : "", "")
1270
+ ).filter((x) => x.trim() !== "").join("/");
1271
+ }
1272
+
1273
+ // util/git_fields.ts
1274
+ function mergeGitMetadataSettings(s1, s2) {
1275
+ if (s1.collect === "all") {
1276
+ return s2;
1277
+ } else if (s2.collect === "all") {
1278
+ return s1;
1279
+ } else if (s1.collect === "none") {
1280
+ return s1;
1281
+ } else if (s2.collect === "none") {
1282
+ return s2;
1283
+ }
1284
+ const fields = (_nullishCoalesce(s1.fields, () => ( []))).filter((f) => (_nullishCoalesce(s2.fields, () => ( []))).includes(f));
1285
+ const collect = fields.length > 0 ? "some" : "none";
1286
+ return { collect, fields };
1287
+ }
324
1288
 
1289
+ // util/xact-ids.ts
1290
+ var TOP_BITS = BigInt("0x0DE1") << BigInt(48);
1291
+ var MOD = BigInt(1) << BigInt(64);
1292
+ var COPRIME = BigInt("205891132094649");
1293
+ var COPRIME_INVERSE = BigInt("1522336535492693385");
1294
+ function modularMultiply(value, prime) {
1295
+ return value * prime % MOD;
1296
+ }
1297
+ function loadPrettyXact(encodedHex) {
1298
+ if (encodedHex.length !== 16) {
1299
+ return encodedHex;
1300
+ }
1301
+ const value = BigInt(`0x${encodedHex}`);
1302
+ const multipliedInverse = modularMultiply(value, COPRIME_INVERSE);
1303
+ const withTopBits = TOP_BITS | multipliedInverse;
1304
+ return withTopBits.toString();
1305
+ }
325
1306
 
1307
+ // util/zod_util.ts
326
1308
 
327
- var _core = require('@braintrust/core');
328
1309
 
329
1310
  // src/generated_types.ts
330
- var _zod = require('zod');
331
- var AclObjectType = _zod.z.union([
332
- _zod.z.enum([
1311
+
1312
+ var AclObjectType = _v3.z.union([
1313
+ _v3.z.enum([
333
1314
  "organization",
334
1315
  "project",
335
1316
  "experiment",
@@ -342,9 +1323,9 @@ var AclObjectType = _zod.z.union([
342
1323
  "project_log",
343
1324
  "org_project"
344
1325
  ]),
345
- _zod.z.null()
1326
+ _v3.z.null()
346
1327
  ]);
347
- var Permission = _zod.z.enum([
1328
+ var Permission = _v3.z.enum([
348
1329
  "create",
349
1330
  "read",
350
1331
  "update",
@@ -354,310 +1335,310 @@ var Permission = _zod.z.enum([
354
1335
  "update_acls",
355
1336
  "delete_acls"
356
1337
  ]);
357
- var Acl = _zod.z.object({
358
- id: _zod.z.string().uuid(),
359
- object_type: AclObjectType.and(_zod.z.string()),
360
- object_id: _zod.z.string().uuid(),
361
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
362
- group_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
363
- permission: Permission.and(_zod.z.union([_zod.z.string(), _zod.z.null()])).optional(),
364
- restrict_object_type: AclObjectType.and(_zod.z.unknown()).optional(),
365
- role_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
366
- _object_org_id: _zod.z.string().uuid(),
367
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1338
+ var Acl = _v3.z.object({
1339
+ id: _v3.z.string().uuid(),
1340
+ object_type: AclObjectType.and(_v3.z.string()),
1341
+ object_id: _v3.z.string().uuid(),
1342
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1343
+ group_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1344
+ permission: Permission.and(_v3.z.union([_v3.z.string(), _v3.z.null()])).optional(),
1345
+ restrict_object_type: AclObjectType.and(_v3.z.unknown()).optional(),
1346
+ role_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1347
+ _object_org_id: _v3.z.string().uuid(),
1348
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
368
1349
  });
369
- var AISecret = _zod.z.object({
370
- id: _zod.z.string().uuid(),
371
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
372
- updated_at: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
373
- org_id: _zod.z.string().uuid(),
374
- name: _zod.z.string(),
375
- type: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
376
- metadata: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.null()]).optional(),
377
- preview_secret: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1350
+ var AISecret = _v3.z.object({
1351
+ id: _v3.z.string().uuid(),
1352
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1353
+ updated_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1354
+ org_id: _v3.z.string().uuid(),
1355
+ name: _v3.z.string(),
1356
+ type: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1357
+ metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional(),
1358
+ preview_secret: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
378
1359
  });
379
- var ResponseFormatJsonSchema = _zod.z.object({
380
- name: _zod.z.string(),
381
- description: _zod.z.string().optional(),
382
- schema: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.string()]).optional(),
383
- strict: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional()
1360
+ var ResponseFormatJsonSchema = _v3.z.object({
1361
+ name: _v3.z.string(),
1362
+ description: _v3.z.string().optional(),
1363
+ schema: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.string()]).optional(),
1364
+ strict: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
384
1365
  });
385
- var ResponseFormatNullish = _zod.z.union([
386
- _zod.z.object({ type: _zod.z.literal("json_object") }),
387
- _zod.z.object({
388
- type: _zod.z.literal("json_schema"),
1366
+ var ResponseFormatNullish = _v3.z.union([
1367
+ _v3.z.object({ type: _v3.z.literal("json_object") }),
1368
+ _v3.z.object({
1369
+ type: _v3.z.literal("json_schema"),
389
1370
  json_schema: ResponseFormatJsonSchema
390
1371
  }),
391
- _zod.z.object({ type: _zod.z.literal("text") }),
392
- _zod.z.null()
1372
+ _v3.z.object({ type: _v3.z.literal("text") }),
1373
+ _v3.z.null()
393
1374
  ]);
394
- var AnyModelParams = _zod.z.object({
395
- temperature: _zod.z.number().optional(),
396
- top_p: _zod.z.number().optional(),
397
- max_tokens: _zod.z.number(),
398
- max_completion_tokens: _zod.z.number().optional(),
399
- frequency_penalty: _zod.z.number().optional(),
400
- presence_penalty: _zod.z.number().optional(),
1375
+ var AnyModelParams = _v3.z.object({
1376
+ temperature: _v3.z.number().optional(),
1377
+ top_p: _v3.z.number().optional(),
1378
+ max_tokens: _v3.z.number(),
1379
+ max_completion_tokens: _v3.z.number().optional(),
1380
+ frequency_penalty: _v3.z.number().optional(),
1381
+ presence_penalty: _v3.z.number().optional(),
401
1382
  response_format: ResponseFormatNullish.optional(),
402
- tool_choice: _zod.z.union([
403
- _zod.z.literal("auto"),
404
- _zod.z.literal("none"),
405
- _zod.z.literal("required"),
406
- _zod.z.object({
407
- type: _zod.z.literal("function"),
408
- function: _zod.z.object({ name: _zod.z.string() })
1383
+ tool_choice: _v3.z.union([
1384
+ _v3.z.literal("auto"),
1385
+ _v3.z.literal("none"),
1386
+ _v3.z.literal("required"),
1387
+ _v3.z.object({
1388
+ type: _v3.z.literal("function"),
1389
+ function: _v3.z.object({ name: _v3.z.string() })
409
1390
  })
410
1391
  ]).optional(),
411
- function_call: _zod.z.union([
412
- _zod.z.literal("auto"),
413
- _zod.z.literal("none"),
414
- _zod.z.object({ name: _zod.z.string() })
1392
+ function_call: _v3.z.union([
1393
+ _v3.z.literal("auto"),
1394
+ _v3.z.literal("none"),
1395
+ _v3.z.object({ name: _v3.z.string() })
415
1396
  ]).optional(),
416
- n: _zod.z.number().optional(),
417
- stop: _zod.z.array(_zod.z.string()).optional(),
418
- reasoning_effort: _zod.z.enum(["minimal", "low", "medium", "high"]).optional(),
419
- verbosity: _zod.z.enum(["low", "medium", "high"]).optional(),
420
- top_k: _zod.z.number().optional(),
421
- stop_sequences: _zod.z.array(_zod.z.string()).optional(),
422
- max_tokens_to_sample: _zod.z.number().optional(),
423
- maxOutputTokens: _zod.z.number().optional(),
424
- topP: _zod.z.number().optional(),
425
- topK: _zod.z.number().optional(),
426
- use_cache: _zod.z.boolean().optional()
1397
+ n: _v3.z.number().optional(),
1398
+ stop: _v3.z.array(_v3.z.string()).optional(),
1399
+ reasoning_effort: _v3.z.enum(["minimal", "low", "medium", "high"]).optional(),
1400
+ verbosity: _v3.z.enum(["low", "medium", "high"]).optional(),
1401
+ top_k: _v3.z.number().optional(),
1402
+ stop_sequences: _v3.z.array(_v3.z.string()).optional(),
1403
+ max_tokens_to_sample: _v3.z.number().optional(),
1404
+ maxOutputTokens: _v3.z.number().optional(),
1405
+ topP: _v3.z.number().optional(),
1406
+ topK: _v3.z.number().optional(),
1407
+ use_cache: _v3.z.boolean().optional()
427
1408
  });
428
- var ApiKey = _zod.z.object({
429
- id: _zod.z.string().uuid(),
430
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
431
- name: _zod.z.string(),
432
- preview_name: _zod.z.string(),
433
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
434
- user_email: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
435
- user_given_name: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
436
- user_family_name: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
437
- org_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1409
+ var ApiKey = _v3.z.object({
1410
+ id: _v3.z.string().uuid(),
1411
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1412
+ name: _v3.z.string(),
1413
+ preview_name: _v3.z.string(),
1414
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1415
+ user_email: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1416
+ user_given_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1417
+ user_family_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1418
+ org_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
438
1419
  });
439
- var AsyncScoringState = _zod.z.union([
440
- _zod.z.object({
441
- status: _zod.z.literal("enabled"),
442
- token: _zod.z.string(),
443
- function_ids: _zod.z.array(_zod.z.unknown()).min(1),
444
- skip_logging: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional()
1420
+ var AsyncScoringState = _v3.z.union([
1421
+ _v3.z.object({
1422
+ status: _v3.z.literal("enabled"),
1423
+ token: _v3.z.string(),
1424
+ function_ids: _v3.z.array(_v3.z.unknown()).min(1),
1425
+ skip_logging: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
445
1426
  }),
446
- _zod.z.object({ status: _zod.z.literal("disabled") }),
447
- _zod.z.null(),
448
- _zod.z.null()
1427
+ _v3.z.object({ status: _v3.z.literal("disabled") }),
1428
+ _v3.z.null(),
1429
+ _v3.z.null()
449
1430
  ]);
450
- var AsyncScoringControl = _zod.z.union([
451
- _zod.z.object({ kind: _zod.z.literal("score_update"), token: _zod.z.string() }),
452
- _zod.z.object({ kind: _zod.z.literal("state_override"), state: AsyncScoringState }),
453
- _zod.z.object({ kind: _zod.z.literal("state_force_reselect") }),
454
- _zod.z.object({ kind: _zod.z.literal("state_enabled_force_rescore") })
1431
+ var AsyncScoringControl = _v3.z.union([
1432
+ _v3.z.object({ kind: _v3.z.literal("score_update"), token: _v3.z.string() }),
1433
+ _v3.z.object({ kind: _v3.z.literal("state_override"), state: AsyncScoringState }),
1434
+ _v3.z.object({ kind: _v3.z.literal("state_force_reselect") }),
1435
+ _v3.z.object({ kind: _v3.z.literal("state_enabled_force_rescore") })
455
1436
  ]);
456
- var BraintrustAttachmentReference = _zod.z.object({
457
- type: _zod.z.literal("braintrust_attachment"),
458
- filename: _zod.z.string().min(1),
459
- content_type: _zod.z.string().min(1),
460
- key: _zod.z.string().min(1)
1437
+ var BraintrustAttachmentReference = _v3.z.object({
1438
+ type: _v3.z.literal("braintrust_attachment"),
1439
+ filename: _v3.z.string().min(1),
1440
+ content_type: _v3.z.string().min(1),
1441
+ key: _v3.z.string().min(1)
461
1442
  });
462
- var ExternalAttachmentReference = _zod.z.object({
463
- type: _zod.z.literal("external_attachment"),
464
- filename: _zod.z.string().min(1),
465
- content_type: _zod.z.string().min(1),
466
- url: _zod.z.string().min(1)
1443
+ var ExternalAttachmentReference = _v3.z.object({
1444
+ type: _v3.z.literal("external_attachment"),
1445
+ filename: _v3.z.string().min(1),
1446
+ content_type: _v3.z.string().min(1),
1447
+ url: _v3.z.string().min(1)
467
1448
  });
468
- var AttachmentReference = _zod.z.discriminatedUnion("type", [
1449
+ var AttachmentReference = _v3.z.discriminatedUnion("type", [
469
1450
  BraintrustAttachmentReference,
470
1451
  ExternalAttachmentReference
471
1452
  ]);
472
- var UploadStatus = _zod.z.enum(["uploading", "done", "error"]);
473
- var AttachmentStatus = _zod.z.object({
1453
+ var UploadStatus = _v3.z.enum(["uploading", "done", "error"]);
1454
+ var AttachmentStatus = _v3.z.object({
474
1455
  upload_status: UploadStatus,
475
- error_message: _zod.z.string().optional()
1456
+ error_message: _v3.z.string().optional()
476
1457
  });
477
- var BraintrustModelParams = _zod.z.object({ use_cache: _zod.z.boolean() }).partial();
478
- var CallEvent = _zod.z.union([
479
- _zod.z.object({
480
- id: _zod.z.string().optional(),
481
- data: _zod.z.string(),
482
- event: _zod.z.literal("text_delta")
1458
+ var BraintrustModelParams = _v3.z.object({ use_cache: _v3.z.boolean() }).partial();
1459
+ var CallEvent = _v3.z.union([
1460
+ _v3.z.object({
1461
+ id: _v3.z.string().optional(),
1462
+ data: _v3.z.string(),
1463
+ event: _v3.z.literal("text_delta")
483
1464
  }),
484
- _zod.z.object({
485
- id: _zod.z.string().optional(),
486
- data: _zod.z.string(),
487
- event: _zod.z.literal("reasoning_delta")
1465
+ _v3.z.object({
1466
+ id: _v3.z.string().optional(),
1467
+ data: _v3.z.string(),
1468
+ event: _v3.z.literal("reasoning_delta")
488
1469
  }),
489
- _zod.z.object({
490
- id: _zod.z.string().optional(),
491
- data: _zod.z.string(),
492
- event: _zod.z.literal("json_delta")
1470
+ _v3.z.object({
1471
+ id: _v3.z.string().optional(),
1472
+ data: _v3.z.string(),
1473
+ event: _v3.z.literal("json_delta")
493
1474
  }),
494
- _zod.z.object({
495
- id: _zod.z.string().optional(),
496
- data: _zod.z.string(),
497
- event: _zod.z.literal("progress")
1475
+ _v3.z.object({
1476
+ id: _v3.z.string().optional(),
1477
+ data: _v3.z.string(),
1478
+ event: _v3.z.literal("progress")
498
1479
  }),
499
- _zod.z.object({
500
- id: _zod.z.string().optional(),
501
- data: _zod.z.string(),
502
- event: _zod.z.literal("error")
1480
+ _v3.z.object({
1481
+ id: _v3.z.string().optional(),
1482
+ data: _v3.z.string(),
1483
+ event: _v3.z.literal("error")
503
1484
  }),
504
- _zod.z.object({
505
- id: _zod.z.string().optional(),
506
- data: _zod.z.string(),
507
- event: _zod.z.literal("console")
1485
+ _v3.z.object({
1486
+ id: _v3.z.string().optional(),
1487
+ data: _v3.z.string(),
1488
+ event: _v3.z.literal("console")
508
1489
  }),
509
- _zod.z.object({
510
- id: _zod.z.string().optional(),
511
- event: _zod.z.literal("start"),
512
- data: _zod.z.literal("")
1490
+ _v3.z.object({
1491
+ id: _v3.z.string().optional(),
1492
+ event: _v3.z.literal("start"),
1493
+ data: _v3.z.literal("")
513
1494
  }),
514
- _zod.z.object({
515
- id: _zod.z.string().optional(),
516
- event: _zod.z.literal("done"),
517
- data: _zod.z.literal("")
1495
+ _v3.z.object({
1496
+ id: _v3.z.string().optional(),
1497
+ event: _v3.z.literal("done"),
1498
+ data: _v3.z.literal("")
518
1499
  })
519
1500
  ]);
520
- var ChatCompletionContentPartTextWithTitle = _zod.z.object({
521
- text: _zod.z.string().default(""),
522
- type: _zod.z.literal("text"),
523
- cache_control: _zod.z.object({ type: _zod.z.literal("ephemeral") }).optional()
1501
+ var ChatCompletionContentPartTextWithTitle = _v3.z.object({
1502
+ text: _v3.z.string().default(""),
1503
+ type: _v3.z.literal("text"),
1504
+ cache_control: _v3.z.object({ type: _v3.z.literal("ephemeral") }).optional()
524
1505
  });
525
- var ChatCompletionContentPartImageWithTitle = _zod.z.object({
526
- image_url: _zod.z.object({
527
- url: _zod.z.string(),
528
- detail: _zod.z.union([_zod.z.literal("auto"), _zod.z.literal("low"), _zod.z.literal("high")]).optional()
1506
+ var ChatCompletionContentPartImageWithTitle = _v3.z.object({
1507
+ image_url: _v3.z.object({
1508
+ url: _v3.z.string(),
1509
+ detail: _v3.z.union([_v3.z.literal("auto"), _v3.z.literal("low"), _v3.z.literal("high")]).optional()
529
1510
  }),
530
- type: _zod.z.literal("image_url")
1511
+ type: _v3.z.literal("image_url")
531
1512
  });
532
- var ChatCompletionContentPart = _zod.z.union([
1513
+ var ChatCompletionContentPart = _v3.z.union([
533
1514
  ChatCompletionContentPartTextWithTitle,
534
1515
  ChatCompletionContentPartImageWithTitle
535
1516
  ]);
536
- var ChatCompletionContentPartText = _zod.z.object({
537
- text: _zod.z.string().default(""),
538
- type: _zod.z.literal("text"),
539
- cache_control: _zod.z.object({ type: _zod.z.literal("ephemeral") }).optional()
1517
+ var ChatCompletionContentPartText = _v3.z.object({
1518
+ text: _v3.z.string().default(""),
1519
+ type: _v3.z.literal("text"),
1520
+ cache_control: _v3.z.object({ type: _v3.z.literal("ephemeral") }).optional()
540
1521
  });
541
- var ChatCompletionMessageToolCall = _zod.z.object({
542
- id: _zod.z.string(),
543
- function: _zod.z.object({ arguments: _zod.z.string(), name: _zod.z.string() }),
544
- type: _zod.z.literal("function")
1522
+ var ChatCompletionMessageToolCall = _v3.z.object({
1523
+ id: _v3.z.string(),
1524
+ function: _v3.z.object({ arguments: _v3.z.string(), name: _v3.z.string() }),
1525
+ type: _v3.z.literal("function")
545
1526
  });
546
- var ChatCompletionMessageReasoning = _zod.z.object({ id: _zod.z.string(), content: _zod.z.string() }).partial();
547
- var ChatCompletionMessageParam = _zod.z.union([
548
- _zod.z.object({
549
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPartText)]),
550
- role: _zod.z.literal("system"),
551
- name: _zod.z.string().optional()
1527
+ var ChatCompletionMessageReasoning = _v3.z.object({ id: _v3.z.string(), content: _v3.z.string() }).partial();
1528
+ var ChatCompletionMessageParam = _v3.z.union([
1529
+ _v3.z.object({
1530
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
1531
+ role: _v3.z.literal("system"),
1532
+ name: _v3.z.string().optional()
552
1533
  }),
553
- _zod.z.object({
554
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPart)]),
555
- role: _zod.z.literal("user"),
556
- name: _zod.z.string().optional()
1534
+ _v3.z.object({
1535
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPart)]),
1536
+ role: _v3.z.literal("user"),
1537
+ name: _v3.z.string().optional()
557
1538
  }),
558
- _zod.z.object({
559
- role: _zod.z.literal("assistant"),
560
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPartText), _zod.z.null()]).optional(),
561
- function_call: _zod.z.object({ arguments: _zod.z.string(), name: _zod.z.string() }).optional(),
562
- name: _zod.z.string().optional(),
563
- tool_calls: _zod.z.array(ChatCompletionMessageToolCall).optional(),
564
- reasoning: _zod.z.array(ChatCompletionMessageReasoning).optional()
1539
+ _v3.z.object({
1540
+ role: _v3.z.literal("assistant"),
1541
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText), _v3.z.null()]).optional(),
1542
+ function_call: _v3.z.object({ arguments: _v3.z.string(), name: _v3.z.string() }).optional(),
1543
+ name: _v3.z.string().optional(),
1544
+ tool_calls: _v3.z.array(ChatCompletionMessageToolCall).optional(),
1545
+ reasoning: _v3.z.array(ChatCompletionMessageReasoning).optional()
565
1546
  }),
566
- _zod.z.object({
567
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPartText)]),
568
- role: _zod.z.literal("tool"),
569
- tool_call_id: _zod.z.string().default("")
1547
+ _v3.z.object({
1548
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
1549
+ role: _v3.z.literal("tool"),
1550
+ tool_call_id: _v3.z.string().default("")
570
1551
  }),
571
- _zod.z.object({
572
- content: _zod.z.union([_zod.z.string(), _zod.z.null()]),
573
- name: _zod.z.string(),
574
- role: _zod.z.literal("function")
1552
+ _v3.z.object({
1553
+ content: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1554
+ name: _v3.z.string(),
1555
+ role: _v3.z.literal("function")
575
1556
  }),
576
- _zod.z.object({
577
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPartText)]),
578
- role: _zod.z.literal("developer"),
579
- name: _zod.z.string().optional()
1557
+ _v3.z.object({
1558
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
1559
+ role: _v3.z.literal("developer"),
1560
+ name: _v3.z.string().optional()
580
1561
  }),
581
- _zod.z.object({
582
- role: _zod.z.literal("model"),
583
- content: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1562
+ _v3.z.object({
1563
+ role: _v3.z.literal("model"),
1564
+ content: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
584
1565
  })
585
1566
  ]);
586
- var ChatCompletionOpenAIMessageParam = _zod.z.union([
587
- _zod.z.object({
588
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPartText)]),
589
- role: _zod.z.literal("system"),
590
- name: _zod.z.string().optional()
1567
+ var ChatCompletionOpenAIMessageParam = _v3.z.union([
1568
+ _v3.z.object({
1569
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
1570
+ role: _v3.z.literal("system"),
1571
+ name: _v3.z.string().optional()
591
1572
  }),
592
- _zod.z.object({
593
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPart)]),
594
- role: _zod.z.literal("user"),
595
- name: _zod.z.string().optional()
1573
+ _v3.z.object({
1574
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPart)]),
1575
+ role: _v3.z.literal("user"),
1576
+ name: _v3.z.string().optional()
596
1577
  }),
597
- _zod.z.object({
598
- role: _zod.z.literal("assistant"),
599
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPartText), _zod.z.null()]).optional(),
600
- function_call: _zod.z.object({ arguments: _zod.z.string(), name: _zod.z.string() }).optional(),
601
- name: _zod.z.string().optional(),
602
- tool_calls: _zod.z.array(ChatCompletionMessageToolCall).optional(),
603
- reasoning: _zod.z.array(ChatCompletionMessageReasoning).optional()
1578
+ _v3.z.object({
1579
+ role: _v3.z.literal("assistant"),
1580
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText), _v3.z.null()]).optional(),
1581
+ function_call: _v3.z.object({ arguments: _v3.z.string(), name: _v3.z.string() }).optional(),
1582
+ name: _v3.z.string().optional(),
1583
+ tool_calls: _v3.z.array(ChatCompletionMessageToolCall).optional(),
1584
+ reasoning: _v3.z.array(ChatCompletionMessageReasoning).optional()
604
1585
  }),
605
- _zod.z.object({
606
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPartText)]),
607
- role: _zod.z.literal("tool"),
608
- tool_call_id: _zod.z.string().default("")
1586
+ _v3.z.object({
1587
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
1588
+ role: _v3.z.literal("tool"),
1589
+ tool_call_id: _v3.z.string().default("")
609
1590
  }),
610
- _zod.z.object({
611
- content: _zod.z.union([_zod.z.string(), _zod.z.null()]),
612
- name: _zod.z.string(),
613
- role: _zod.z.literal("function")
1591
+ _v3.z.object({
1592
+ content: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1593
+ name: _v3.z.string(),
1594
+ role: _v3.z.literal("function")
614
1595
  }),
615
- _zod.z.object({
616
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPartText)]),
617
- role: _zod.z.literal("developer"),
618
- name: _zod.z.string().optional()
1596
+ _v3.z.object({
1597
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
1598
+ role: _v3.z.literal("developer"),
1599
+ name: _v3.z.string().optional()
619
1600
  })
620
1601
  ]);
621
- var ChatCompletionTool = _zod.z.object({
622
- function: _zod.z.object({
623
- name: _zod.z.string(),
624
- description: _zod.z.string().optional(),
625
- parameters: _zod.z.object({}).partial().passthrough().optional()
1602
+ var ChatCompletionTool = _v3.z.object({
1603
+ function: _v3.z.object({
1604
+ name: _v3.z.string(),
1605
+ description: _v3.z.string().optional(),
1606
+ parameters: _v3.z.object({}).partial().passthrough().optional()
626
1607
  }),
627
- type: _zod.z.literal("function")
1608
+ type: _v3.z.literal("function")
628
1609
  });
629
- var CodeBundle = _zod.z.object({
630
- runtime_context: _zod.z.object({
631
- runtime: _zod.z.enum(["node", "python"]),
632
- version: _zod.z.string()
1610
+ var CodeBundle = _v3.z.object({
1611
+ runtime_context: _v3.z.object({
1612
+ runtime: _v3.z.enum(["node", "python"]),
1613
+ version: _v3.z.string()
633
1614
  }),
634
- location: _zod.z.union([
635
- _zod.z.object({
636
- type: _zod.z.literal("experiment"),
637
- eval_name: _zod.z.string(),
638
- position: _zod.z.union([
639
- _zod.z.object({ type: _zod.z.literal("task") }),
640
- _zod.z.object({ type: _zod.z.literal("scorer"), index: _zod.z.number().int().gte(0) })
1615
+ location: _v3.z.union([
1616
+ _v3.z.object({
1617
+ type: _v3.z.literal("experiment"),
1618
+ eval_name: _v3.z.string(),
1619
+ position: _v3.z.union([
1620
+ _v3.z.object({ type: _v3.z.literal("task") }),
1621
+ _v3.z.object({ type: _v3.z.literal("scorer"), index: _v3.z.number().int().gte(0) })
641
1622
  ])
642
1623
  }),
643
- _zod.z.object({ type: _zod.z.literal("function"), index: _zod.z.number().int().gte(0) })
1624
+ _v3.z.object({ type: _v3.z.literal("function"), index: _v3.z.number().int().gte(0) })
644
1625
  ]),
645
- bundle_id: _zod.z.string(),
646
- preview: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1626
+ bundle_id: _v3.z.string(),
1627
+ preview: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
647
1628
  });
648
- var Dataset = _zod.z.object({
649
- id: _zod.z.string().uuid(),
650
- project_id: _zod.z.string().uuid(),
651
- name: _zod.z.string(),
652
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
653
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
654
- deleted_at: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
655
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
656
- metadata: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.null()]).optional()
1629
+ var Dataset = _v3.z.object({
1630
+ id: _v3.z.string().uuid(),
1631
+ project_id: _v3.z.string().uuid(),
1632
+ name: _v3.z.string(),
1633
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1634
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1635
+ deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1636
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1637
+ metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional()
657
1638
  });
658
- var ObjectReferenceNullish = _zod.z.union([
659
- _zod.z.object({
660
- object_type: _zod.z.enum([
1639
+ var ObjectReferenceNullish = _v3.z.union([
1640
+ _v3.z.object({
1641
+ object_type: _v3.z.enum([
661
1642
  "project_logs",
662
1643
  "experiment",
663
1644
  "dataset",
@@ -665,399 +1646,399 @@ var ObjectReferenceNullish = _zod.z.union([
665
1646
  "function",
666
1647
  "prompt_session"
667
1648
  ]),
668
- object_id: _zod.z.string().uuid(),
669
- id: _zod.z.string(),
670
- _xact_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
671
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1649
+ object_id: _v3.z.string().uuid(),
1650
+ id: _v3.z.string(),
1651
+ _xact_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1652
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
672
1653
  }),
673
- _zod.z.null()
1654
+ _v3.z.null()
674
1655
  ]);
675
- var DatasetEvent = _zod.z.object({
676
- id: _zod.z.string(),
677
- _xact_id: _zod.z.string(),
678
- created: _zod.z.string().datetime({ offset: true }),
679
- _pagination_key: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
680
- project_id: _zod.z.string().uuid(),
681
- dataset_id: _zod.z.string().uuid(),
682
- input: _zod.z.unknown().optional(),
683
- expected: _zod.z.unknown().optional(),
684
- metadata: _zod.z.union([
685
- _zod.z.object({ model: _zod.z.union([_zod.z.string(), _zod.z.null()]) }).partial().passthrough(),
686
- _zod.z.null()
1656
+ var DatasetEvent = _v3.z.object({
1657
+ id: _v3.z.string(),
1658
+ _xact_id: _v3.z.string(),
1659
+ created: _v3.z.string().datetime({ offset: true }),
1660
+ _pagination_key: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1661
+ project_id: _v3.z.string().uuid(),
1662
+ dataset_id: _v3.z.string().uuid(),
1663
+ input: _v3.z.unknown().optional(),
1664
+ expected: _v3.z.unknown().optional(),
1665
+ metadata: _v3.z.union([
1666
+ _v3.z.object({ model: _v3.z.union([_v3.z.string(), _v3.z.null()]) }).partial().passthrough(),
1667
+ _v3.z.null()
687
1668
  ]).optional(),
688
- tags: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional(),
689
- span_id: _zod.z.string(),
690
- root_span_id: _zod.z.string(),
691
- is_root: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional(),
1669
+ tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
1670
+ span_id: _v3.z.string(),
1671
+ root_span_id: _v3.z.string(),
1672
+ is_root: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
692
1673
  origin: ObjectReferenceNullish.optional()
693
1674
  });
694
- var EnvVar = _zod.z.object({
695
- id: _zod.z.string().uuid(),
696
- object_type: _zod.z.enum(["organization", "project", "function"]),
697
- object_id: _zod.z.string().uuid(),
698
- name: _zod.z.string(),
699
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
700
- used: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1675
+ var EnvVar = _v3.z.object({
1676
+ id: _v3.z.string().uuid(),
1677
+ object_type: _v3.z.enum(["organization", "project", "function"]),
1678
+ object_id: _v3.z.string().uuid(),
1679
+ name: _v3.z.string(),
1680
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1681
+ used: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
701
1682
  });
702
- var RepoInfo = _zod.z.union([
703
- _zod.z.object({
704
- commit: _zod.z.union([_zod.z.string(), _zod.z.null()]),
705
- branch: _zod.z.union([_zod.z.string(), _zod.z.null()]),
706
- tag: _zod.z.union([_zod.z.string(), _zod.z.null()]),
707
- dirty: _zod.z.union([_zod.z.boolean(), _zod.z.null()]),
708
- author_name: _zod.z.union([_zod.z.string(), _zod.z.null()]),
709
- author_email: _zod.z.union([_zod.z.string(), _zod.z.null()]),
710
- commit_message: _zod.z.union([_zod.z.string(), _zod.z.null()]),
711
- commit_time: _zod.z.union([_zod.z.string(), _zod.z.null()]),
712
- git_diff: _zod.z.union([_zod.z.string(), _zod.z.null()])
1683
+ var RepoInfo = _v3.z.union([
1684
+ _v3.z.object({
1685
+ commit: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1686
+ branch: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1687
+ tag: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1688
+ dirty: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
1689
+ author_name: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1690
+ author_email: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1691
+ commit_message: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1692
+ commit_time: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1693
+ git_diff: _v3.z.union([_v3.z.string(), _v3.z.null()])
713
1694
  }).partial(),
714
- _zod.z.null()
1695
+ _v3.z.null()
715
1696
  ]);
716
- var Experiment = _zod.z.object({
717
- id: _zod.z.string().uuid(),
718
- project_id: _zod.z.string().uuid(),
719
- name: _zod.z.string(),
720
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
721
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1697
+ var Experiment = _v3.z.object({
1698
+ id: _v3.z.string().uuid(),
1699
+ project_id: _v3.z.string().uuid(),
1700
+ name: _v3.z.string(),
1701
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1702
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
722
1703
  repo_info: RepoInfo.optional(),
723
- commit: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
724
- base_exp_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
725
- deleted_at: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
726
- dataset_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
727
- dataset_version: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
728
- public: _zod.z.boolean(),
729
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
730
- metadata: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.null()]).optional(),
731
- tags: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional()
1704
+ commit: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1705
+ base_exp_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1706
+ deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1707
+ dataset_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1708
+ dataset_version: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1709
+ public: _v3.z.boolean(),
1710
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1711
+ metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional(),
1712
+ tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional()
732
1713
  });
733
- var SpanType = _zod.z.union([
734
- _zod.z.enum(["llm", "score", "function", "eval", "task", "tool"]),
735
- _zod.z.null()
1714
+ var SpanType = _v3.z.union([
1715
+ _v3.z.enum(["llm", "score", "function", "eval", "task", "tool"]),
1716
+ _v3.z.null()
736
1717
  ]);
737
- var SpanAttributes = _zod.z.union([
738
- _zod.z.object({ name: _zod.z.union([_zod.z.string(), _zod.z.null()]), type: SpanType }).partial().passthrough(),
739
- _zod.z.null()
1718
+ var SpanAttributes = _v3.z.union([
1719
+ _v3.z.object({ name: _v3.z.union([_v3.z.string(), _v3.z.null()]), type: SpanType }).partial().passthrough(),
1720
+ _v3.z.null()
740
1721
  ]);
741
- var ExperimentEvent = _zod.z.object({
742
- id: _zod.z.string(),
743
- _xact_id: _zod.z.string(),
744
- created: _zod.z.string().datetime({ offset: true }),
745
- _pagination_key: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
746
- project_id: _zod.z.string().uuid(),
747
- experiment_id: _zod.z.string().uuid(),
748
- input: _zod.z.unknown().optional(),
749
- output: _zod.z.unknown().optional(),
750
- expected: _zod.z.unknown().optional(),
751
- error: _zod.z.unknown().optional(),
752
- scores: _zod.z.union([_zod.z.record(_zod.z.union([_zod.z.number(), _zod.z.null()])), _zod.z.null()]).optional(),
753
- metadata: _zod.z.union([
754
- _zod.z.object({ model: _zod.z.union([_zod.z.string(), _zod.z.null()]) }).partial().passthrough(),
755
- _zod.z.null()
1722
+ var ExperimentEvent = _v3.z.object({
1723
+ id: _v3.z.string(),
1724
+ _xact_id: _v3.z.string(),
1725
+ created: _v3.z.string().datetime({ offset: true }),
1726
+ _pagination_key: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1727
+ project_id: _v3.z.string().uuid(),
1728
+ experiment_id: _v3.z.string().uuid(),
1729
+ input: _v3.z.unknown().optional(),
1730
+ output: _v3.z.unknown().optional(),
1731
+ expected: _v3.z.unknown().optional(),
1732
+ error: _v3.z.unknown().optional(),
1733
+ scores: _v3.z.union([_v3.z.record(_v3.z.union([_v3.z.number(), _v3.z.null()])), _v3.z.null()]).optional(),
1734
+ metadata: _v3.z.union([
1735
+ _v3.z.object({ model: _v3.z.union([_v3.z.string(), _v3.z.null()]) }).partial().passthrough(),
1736
+ _v3.z.null()
756
1737
  ]).optional(),
757
- tags: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional(),
758
- metrics: _zod.z.union([_zod.z.record(_zod.z.number()), _zod.z.null()]).optional(),
759
- context: _zod.z.union([
760
- _zod.z.object({
761
- caller_functionname: _zod.z.union([_zod.z.string(), _zod.z.null()]),
762
- caller_filename: _zod.z.union([_zod.z.string(), _zod.z.null()]),
763
- caller_lineno: _zod.z.union([_zod.z.number(), _zod.z.null()])
1738
+ tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
1739
+ metrics: _v3.z.union([_v3.z.record(_v3.z.number()), _v3.z.null()]).optional(),
1740
+ context: _v3.z.union([
1741
+ _v3.z.object({
1742
+ caller_functionname: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1743
+ caller_filename: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1744
+ caller_lineno: _v3.z.union([_v3.z.number(), _v3.z.null()])
764
1745
  }).partial().passthrough(),
765
- _zod.z.null()
1746
+ _v3.z.null()
766
1747
  ]).optional(),
767
- span_id: _zod.z.string(),
768
- span_parents: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional(),
769
- root_span_id: _zod.z.string(),
1748
+ span_id: _v3.z.string(),
1749
+ span_parents: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
1750
+ root_span_id: _v3.z.string(),
770
1751
  span_attributes: SpanAttributes.optional(),
771
- is_root: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional(),
1752
+ is_root: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
772
1753
  origin: ObjectReferenceNullish.optional()
773
1754
  });
774
- var ExtendedSavedFunctionId = _zod.z.union([
775
- _zod.z.object({ type: _zod.z.literal("function"), id: _zod.z.string() }),
776
- _zod.z.object({ type: _zod.z.literal("global"), name: _zod.z.string() }),
777
- _zod.z.object({
778
- type: _zod.z.literal("slug"),
779
- project_id: _zod.z.string(),
780
- slug: _zod.z.string()
1755
+ var ExtendedSavedFunctionId = _v3.z.union([
1756
+ _v3.z.object({ type: _v3.z.literal("function"), id: _v3.z.string() }),
1757
+ _v3.z.object({ type: _v3.z.literal("global"), name: _v3.z.string() }),
1758
+ _v3.z.object({
1759
+ type: _v3.z.literal("slug"),
1760
+ project_id: _v3.z.string(),
1761
+ slug: _v3.z.string()
781
1762
  })
782
1763
  ]);
783
- var PromptBlockDataNullish = _zod.z.union([
784
- _zod.z.object({ type: _zod.z.literal("completion"), content: _zod.z.string() }),
785
- _zod.z.object({
786
- type: _zod.z.literal("chat"),
787
- messages: _zod.z.array(ChatCompletionMessageParam),
788
- tools: _zod.z.string().optional()
1764
+ var PromptBlockDataNullish = _v3.z.union([
1765
+ _v3.z.object({ type: _v3.z.literal("completion"), content: _v3.z.string() }),
1766
+ _v3.z.object({
1767
+ type: _v3.z.literal("chat"),
1768
+ messages: _v3.z.array(ChatCompletionMessageParam),
1769
+ tools: _v3.z.string().optional()
789
1770
  }),
790
- _zod.z.null()
1771
+ _v3.z.null()
791
1772
  ]);
792
- var ModelParams = _zod.z.union([
793
- _zod.z.object({
794
- use_cache: _zod.z.boolean(),
795
- temperature: _zod.z.number(),
796
- top_p: _zod.z.number(),
797
- max_tokens: _zod.z.number(),
798
- max_completion_tokens: _zod.z.number(),
799
- frequency_penalty: _zod.z.number(),
800
- presence_penalty: _zod.z.number(),
1773
+ var ModelParams = _v3.z.union([
1774
+ _v3.z.object({
1775
+ use_cache: _v3.z.boolean(),
1776
+ temperature: _v3.z.number(),
1777
+ top_p: _v3.z.number(),
1778
+ max_tokens: _v3.z.number(),
1779
+ max_completion_tokens: _v3.z.number(),
1780
+ frequency_penalty: _v3.z.number(),
1781
+ presence_penalty: _v3.z.number(),
801
1782
  response_format: ResponseFormatNullish,
802
- tool_choice: _zod.z.union([
803
- _zod.z.literal("auto"),
804
- _zod.z.literal("none"),
805
- _zod.z.literal("required"),
806
- _zod.z.object({
807
- type: _zod.z.literal("function"),
808
- function: _zod.z.object({ name: _zod.z.string() })
1783
+ tool_choice: _v3.z.union([
1784
+ _v3.z.literal("auto"),
1785
+ _v3.z.literal("none"),
1786
+ _v3.z.literal("required"),
1787
+ _v3.z.object({
1788
+ type: _v3.z.literal("function"),
1789
+ function: _v3.z.object({ name: _v3.z.string() })
809
1790
  })
810
1791
  ]),
811
- function_call: _zod.z.union([
812
- _zod.z.literal("auto"),
813
- _zod.z.literal("none"),
814
- _zod.z.object({ name: _zod.z.string() })
1792
+ function_call: _v3.z.union([
1793
+ _v3.z.literal("auto"),
1794
+ _v3.z.literal("none"),
1795
+ _v3.z.object({ name: _v3.z.string() })
815
1796
  ]),
816
- n: _zod.z.number(),
817
- stop: _zod.z.array(_zod.z.string()),
818
- reasoning_effort: _zod.z.enum(["minimal", "low", "medium", "high"]),
819
- verbosity: _zod.z.enum(["low", "medium", "high"])
1797
+ n: _v3.z.number(),
1798
+ stop: _v3.z.array(_v3.z.string()),
1799
+ reasoning_effort: _v3.z.enum(["minimal", "low", "medium", "high"]),
1800
+ verbosity: _v3.z.enum(["low", "medium", "high"])
820
1801
  }).partial().passthrough(),
821
- _zod.z.object({
822
- use_cache: _zod.z.boolean().optional(),
823
- max_tokens: _zod.z.number(),
824
- temperature: _zod.z.number(),
825
- top_p: _zod.z.number().optional(),
826
- top_k: _zod.z.number().optional(),
827
- stop_sequences: _zod.z.array(_zod.z.string()).optional(),
828
- max_tokens_to_sample: _zod.z.number().optional()
1802
+ _v3.z.object({
1803
+ use_cache: _v3.z.boolean().optional(),
1804
+ max_tokens: _v3.z.number(),
1805
+ temperature: _v3.z.number(),
1806
+ top_p: _v3.z.number().optional(),
1807
+ top_k: _v3.z.number().optional(),
1808
+ stop_sequences: _v3.z.array(_v3.z.string()).optional(),
1809
+ max_tokens_to_sample: _v3.z.number().optional()
829
1810
  }).passthrough(),
830
- _zod.z.object({
831
- use_cache: _zod.z.boolean(),
832
- temperature: _zod.z.number(),
833
- maxOutputTokens: _zod.z.number(),
834
- topP: _zod.z.number(),
835
- topK: _zod.z.number()
1811
+ _v3.z.object({
1812
+ use_cache: _v3.z.boolean(),
1813
+ temperature: _v3.z.number(),
1814
+ maxOutputTokens: _v3.z.number(),
1815
+ topP: _v3.z.number(),
1816
+ topK: _v3.z.number()
836
1817
  }).partial().passthrough(),
837
- _zod.z.object({
838
- use_cache: _zod.z.boolean(),
839
- temperature: _zod.z.number(),
840
- topK: _zod.z.number()
1818
+ _v3.z.object({
1819
+ use_cache: _v3.z.boolean(),
1820
+ temperature: _v3.z.number(),
1821
+ topK: _v3.z.number()
841
1822
  }).partial().passthrough(),
842
- _zod.z.object({ use_cache: _zod.z.boolean() }).partial().passthrough()
1823
+ _v3.z.object({ use_cache: _v3.z.boolean() }).partial().passthrough()
843
1824
  ]);
844
- var PromptOptionsNullish = _zod.z.union([
845
- _zod.z.object({ model: _zod.z.string(), params: ModelParams, position: _zod.z.string() }).partial(),
846
- _zod.z.null()
1825
+ var PromptOptionsNullish = _v3.z.union([
1826
+ _v3.z.object({ model: _v3.z.string(), params: ModelParams, position: _v3.z.string() }).partial(),
1827
+ _v3.z.null()
847
1828
  ]);
848
- var PromptParserNullish = _zod.z.union([
849
- _zod.z.object({
850
- type: _zod.z.literal("llm_classifier"),
851
- use_cot: _zod.z.boolean(),
852
- choice_scores: _zod.z.record(_zod.z.number().gte(0).lte(1))
1829
+ var PromptParserNullish = _v3.z.union([
1830
+ _v3.z.object({
1831
+ type: _v3.z.literal("llm_classifier"),
1832
+ use_cot: _v3.z.boolean(),
1833
+ choice_scores: _v3.z.record(_v3.z.number().gte(0).lte(1))
853
1834
  }),
854
- _zod.z.null()
1835
+ _v3.z.null()
855
1836
  ]);
856
- var SavedFunctionId = _zod.z.union([
857
- _zod.z.object({ type: _zod.z.literal("function"), id: _zod.z.string() }),
858
- _zod.z.object({ type: _zod.z.literal("global"), name: _zod.z.string() })
1837
+ var SavedFunctionId = _v3.z.union([
1838
+ _v3.z.object({ type: _v3.z.literal("function"), id: _v3.z.string() }),
1839
+ _v3.z.object({ type: _v3.z.literal("global"), name: _v3.z.string() })
859
1840
  ]);
860
- var PromptDataNullish = _zod.z.union([
861
- _zod.z.object({
1841
+ var PromptDataNullish = _v3.z.union([
1842
+ _v3.z.object({
862
1843
  prompt: PromptBlockDataNullish,
863
1844
  options: PromptOptionsNullish,
864
1845
  parser: PromptParserNullish,
865
- tool_functions: _zod.z.union([_zod.z.array(SavedFunctionId), _zod.z.null()]),
866
- origin: _zod.z.union([
867
- _zod.z.object({
868
- prompt_id: _zod.z.string(),
869
- project_id: _zod.z.string(),
870
- prompt_version: _zod.z.string()
1846
+ tool_functions: _v3.z.union([_v3.z.array(SavedFunctionId), _v3.z.null()]),
1847
+ origin: _v3.z.union([
1848
+ _v3.z.object({
1849
+ prompt_id: _v3.z.string(),
1850
+ project_id: _v3.z.string(),
1851
+ prompt_version: _v3.z.string()
871
1852
  }).partial(),
872
- _zod.z.null()
1853
+ _v3.z.null()
873
1854
  ])
874
1855
  }).partial(),
875
- _zod.z.null()
1856
+ _v3.z.null()
876
1857
  ]);
877
- var FunctionTypeEnumNullish = _zod.z.union([
878
- _zod.z.enum(["llm", "scorer", "task", "tool"]),
879
- _zod.z.null()
1858
+ var FunctionTypeEnumNullish = _v3.z.union([
1859
+ _v3.z.enum(["llm", "scorer", "task", "tool"]),
1860
+ _v3.z.null()
880
1861
  ]);
881
- var FunctionIdRef = _zod.z.object({}).partial().passthrough();
882
- var PromptBlockData = _zod.z.union([
883
- _zod.z.object({ type: _zod.z.literal("completion"), content: _zod.z.string() }),
884
- _zod.z.object({
885
- type: _zod.z.literal("chat"),
886
- messages: _zod.z.array(ChatCompletionMessageParam),
887
- tools: _zod.z.string().optional()
1862
+ var FunctionIdRef = _v3.z.object({}).partial().passthrough();
1863
+ var PromptBlockData = _v3.z.union([
1864
+ _v3.z.object({ type: _v3.z.literal("completion"), content: _v3.z.string() }),
1865
+ _v3.z.object({
1866
+ type: _v3.z.literal("chat"),
1867
+ messages: _v3.z.array(ChatCompletionMessageParam),
1868
+ tools: _v3.z.string().optional()
888
1869
  })
889
1870
  ]);
890
- var GraphNode = _zod.z.union([
891
- _zod.z.object({
892
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
893
- position: _zod.z.union([_zod.z.object({ x: _zod.z.number(), y: _zod.z.number() }), _zod.z.null()]).optional(),
894
- type: _zod.z.literal("function"),
1871
+ var GraphNode = _v3.z.union([
1872
+ _v3.z.object({
1873
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1874
+ position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
1875
+ type: _v3.z.literal("function"),
895
1876
  function: FunctionIdRef
896
1877
  }),
897
- _zod.z.object({
898
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
899
- position: _zod.z.union([_zod.z.object({ x: _zod.z.number(), y: _zod.z.number() }), _zod.z.null()]).optional(),
900
- type: _zod.z.literal("input")
1878
+ _v3.z.object({
1879
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1880
+ position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
1881
+ type: _v3.z.literal("input")
901
1882
  }),
902
- _zod.z.object({
903
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
904
- position: _zod.z.union([_zod.z.object({ x: _zod.z.number(), y: _zod.z.number() }), _zod.z.null()]).optional(),
905
- type: _zod.z.literal("output")
1883
+ _v3.z.object({
1884
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1885
+ position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
1886
+ type: _v3.z.literal("output")
906
1887
  }),
907
- _zod.z.object({
908
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
909
- position: _zod.z.union([_zod.z.object({ x: _zod.z.number(), y: _zod.z.number() }), _zod.z.null()]).optional(),
910
- type: _zod.z.literal("literal"),
911
- value: _zod.z.unknown().optional()
1888
+ _v3.z.object({
1889
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1890
+ position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
1891
+ type: _v3.z.literal("literal"),
1892
+ value: _v3.z.unknown().optional()
912
1893
  }),
913
- _zod.z.object({
914
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
915
- position: _zod.z.union([_zod.z.object({ x: _zod.z.number(), y: _zod.z.number() }), _zod.z.null()]).optional(),
916
- type: _zod.z.literal("btql"),
917
- expr: _zod.z.string()
1894
+ _v3.z.object({
1895
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1896
+ position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
1897
+ type: _v3.z.literal("btql"),
1898
+ expr: _v3.z.string()
918
1899
  }),
919
- _zod.z.object({
920
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
921
- position: _zod.z.union([_zod.z.object({ x: _zod.z.number(), y: _zod.z.number() }), _zod.z.null()]).optional(),
922
- type: _zod.z.literal("gate"),
923
- condition: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1900
+ _v3.z.object({
1901
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1902
+ position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
1903
+ type: _v3.z.literal("gate"),
1904
+ condition: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
924
1905
  }),
925
- _zod.z.object({
926
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
927
- position: _zod.z.union([_zod.z.object({ x: _zod.z.number(), y: _zod.z.number() }), _zod.z.null()]).optional(),
928
- type: _zod.z.literal("aggregator")
1906
+ _v3.z.object({
1907
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1908
+ position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
1909
+ type: _v3.z.literal("aggregator")
929
1910
  }),
930
- _zod.z.object({
931
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
932
- position: _zod.z.union([_zod.z.object({ x: _zod.z.number(), y: _zod.z.number() }), _zod.z.null()]).optional(),
933
- type: _zod.z.literal("prompt_template"),
1911
+ _v3.z.object({
1912
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1913
+ position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
1914
+ type: _v3.z.literal("prompt_template"),
934
1915
  prompt: PromptBlockData
935
1916
  })
936
1917
  ]);
937
- var GraphEdge = _zod.z.object({
938
- source: _zod.z.object({ node: _zod.z.string().max(1024), variable: _zod.z.string() }),
939
- target: _zod.z.object({ node: _zod.z.string().max(1024), variable: _zod.z.string() }),
940
- purpose: _zod.z.enum(["control", "data", "messages"])
1918
+ var GraphEdge = _v3.z.object({
1919
+ source: _v3.z.object({ node: _v3.z.string().max(1024), variable: _v3.z.string() }),
1920
+ target: _v3.z.object({ node: _v3.z.string().max(1024), variable: _v3.z.string() }),
1921
+ purpose: _v3.z.enum(["control", "data", "messages"])
941
1922
  });
942
- var GraphData = _zod.z.object({
943
- type: _zod.z.literal("graph"),
944
- nodes: _zod.z.record(GraphNode),
945
- edges: _zod.z.record(GraphEdge)
1923
+ var GraphData = _v3.z.object({
1924
+ type: _v3.z.literal("graph"),
1925
+ nodes: _v3.z.record(GraphNode),
1926
+ edges: _v3.z.record(GraphEdge)
946
1927
  });
947
- var FunctionData = _zod.z.union([
948
- _zod.z.object({ type: _zod.z.literal("prompt") }),
949
- _zod.z.object({
950
- type: _zod.z.literal("code"),
951
- data: _zod.z.union([
952
- _zod.z.object({ type: _zod.z.literal("bundle") }).and(CodeBundle),
953
- _zod.z.object({
954
- type: _zod.z.literal("inline"),
955
- runtime_context: _zod.z.object({
956
- runtime: _zod.z.enum(["node", "python"]),
957
- version: _zod.z.string()
1928
+ var FunctionData = _v3.z.union([
1929
+ _v3.z.object({ type: _v3.z.literal("prompt") }),
1930
+ _v3.z.object({
1931
+ type: _v3.z.literal("code"),
1932
+ data: _v3.z.union([
1933
+ _v3.z.object({ type: _v3.z.literal("bundle") }).and(CodeBundle),
1934
+ _v3.z.object({
1935
+ type: _v3.z.literal("inline"),
1936
+ runtime_context: _v3.z.object({
1937
+ runtime: _v3.z.enum(["node", "python"]),
1938
+ version: _v3.z.string()
958
1939
  }),
959
- code: _zod.z.string()
1940
+ code: _v3.z.string()
960
1941
  })
961
1942
  ])
962
1943
  }),
963
1944
  GraphData,
964
- _zod.z.object({
965
- type: _zod.z.literal("remote_eval"),
966
- endpoint: _zod.z.string(),
967
- eval_name: _zod.z.string(),
968
- parameters: _zod.z.object({}).partial().passthrough()
1945
+ _v3.z.object({
1946
+ type: _v3.z.literal("remote_eval"),
1947
+ endpoint: _v3.z.string(),
1948
+ eval_name: _v3.z.string(),
1949
+ parameters: _v3.z.object({}).partial().passthrough()
969
1950
  }),
970
- _zod.z.object({ type: _zod.z.literal("global"), name: _zod.z.string() })
1951
+ _v3.z.object({ type: _v3.z.literal("global"), name: _v3.z.string() })
971
1952
  ]);
972
- var Function = _zod.z.object({
973
- id: _zod.z.string().uuid(),
974
- _xact_id: _zod.z.string(),
975
- project_id: _zod.z.string().uuid(),
976
- log_id: _zod.z.literal("p"),
977
- org_id: _zod.z.string().uuid(),
978
- name: _zod.z.string(),
979
- slug: _zod.z.string(),
980
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
981
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1953
+ var Function = _v3.z.object({
1954
+ id: _v3.z.string().uuid(),
1955
+ _xact_id: _v3.z.string(),
1956
+ project_id: _v3.z.string().uuid(),
1957
+ log_id: _v3.z.literal("p"),
1958
+ org_id: _v3.z.string().uuid(),
1959
+ name: _v3.z.string(),
1960
+ slug: _v3.z.string(),
1961
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1962
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
982
1963
  prompt_data: PromptDataNullish.optional(),
983
- tags: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional(),
984
- metadata: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.null()]).optional(),
1964
+ tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
1965
+ metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional(),
985
1966
  function_type: FunctionTypeEnumNullish.optional(),
986
1967
  function_data: FunctionData,
987
- origin: _zod.z.union([
988
- _zod.z.object({
989
- object_type: AclObjectType.and(_zod.z.string()),
990
- object_id: _zod.z.string().uuid(),
991
- internal: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional()
1968
+ origin: _v3.z.union([
1969
+ _v3.z.object({
1970
+ object_type: AclObjectType.and(_v3.z.string()),
1971
+ object_id: _v3.z.string().uuid(),
1972
+ internal: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
992
1973
  }),
993
- _zod.z.null()
1974
+ _v3.z.null()
994
1975
  ]).optional(),
995
- function_schema: _zod.z.union([
996
- _zod.z.object({ parameters: _zod.z.unknown(), returns: _zod.z.unknown() }).partial(),
997
- _zod.z.null()
1976
+ function_schema: _v3.z.union([
1977
+ _v3.z.object({ parameters: _v3.z.unknown(), returns: _v3.z.unknown() }).partial(),
1978
+ _v3.z.null()
998
1979
  ]).optional()
999
1980
  });
1000
- var FunctionFormat = _zod.z.enum(["llm", "code", "global", "graph"]);
1001
- var PromptData = _zod.z.object({
1981
+ var FunctionFormat = _v3.z.enum(["llm", "code", "global", "graph"]);
1982
+ var PromptData = _v3.z.object({
1002
1983
  prompt: PromptBlockDataNullish,
1003
1984
  options: PromptOptionsNullish,
1004
1985
  parser: PromptParserNullish,
1005
- tool_functions: _zod.z.union([_zod.z.array(SavedFunctionId), _zod.z.null()]),
1006
- origin: _zod.z.union([
1007
- _zod.z.object({
1008
- prompt_id: _zod.z.string(),
1009
- project_id: _zod.z.string(),
1010
- prompt_version: _zod.z.string()
1986
+ tool_functions: _v3.z.union([_v3.z.array(SavedFunctionId), _v3.z.null()]),
1987
+ origin: _v3.z.union([
1988
+ _v3.z.object({
1989
+ prompt_id: _v3.z.string(),
1990
+ project_id: _v3.z.string(),
1991
+ prompt_version: _v3.z.string()
1011
1992
  }).partial(),
1012
- _zod.z.null()
1993
+ _v3.z.null()
1013
1994
  ])
1014
1995
  }).partial();
1015
- var FunctionTypeEnum = _zod.z.enum(["llm", "scorer", "task", "tool"]);
1016
- var FunctionId = _zod.z.union([
1017
- _zod.z.object({ function_id: _zod.z.string(), version: _zod.z.string().optional() }),
1018
- _zod.z.object({
1019
- project_name: _zod.z.string(),
1020
- slug: _zod.z.string(),
1021
- version: _zod.z.string().optional()
1996
+ var FunctionTypeEnum = _v3.z.enum(["llm", "scorer", "task", "tool"]);
1997
+ var FunctionId = _v3.z.union([
1998
+ _v3.z.object({ function_id: _v3.z.string(), version: _v3.z.string().optional() }),
1999
+ _v3.z.object({
2000
+ project_name: _v3.z.string(),
2001
+ slug: _v3.z.string(),
2002
+ version: _v3.z.string().optional()
1022
2003
  }),
1023
- _zod.z.object({ global_function: _zod.z.string() }),
1024
- _zod.z.object({
1025
- prompt_session_id: _zod.z.string(),
1026
- prompt_session_function_id: _zod.z.string(),
1027
- version: _zod.z.string().optional()
2004
+ _v3.z.object({ global_function: _v3.z.string() }),
2005
+ _v3.z.object({
2006
+ prompt_session_id: _v3.z.string(),
2007
+ prompt_session_function_id: _v3.z.string(),
2008
+ version: _v3.z.string().optional()
1028
2009
  }),
1029
- _zod.z.object({
1030
- inline_context: _zod.z.object({
1031
- runtime: _zod.z.enum(["node", "python"]),
1032
- version: _zod.z.string()
2010
+ _v3.z.object({
2011
+ inline_context: _v3.z.object({
2012
+ runtime: _v3.z.enum(["node", "python"]),
2013
+ version: _v3.z.string()
1033
2014
  }),
1034
- code: _zod.z.string(),
1035
- name: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
2015
+ code: _v3.z.string(),
2016
+ name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
1036
2017
  }),
1037
- _zod.z.object({
2018
+ _v3.z.object({
1038
2019
  inline_prompt: PromptData.optional(),
1039
- inline_function: _zod.z.object({}).partial().passthrough(),
2020
+ inline_function: _v3.z.object({}).partial().passthrough(),
1040
2021
  function_type: FunctionTypeEnum.optional(),
1041
- name: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
2022
+ name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
1042
2023
  }),
1043
- _zod.z.object({
2024
+ _v3.z.object({
1044
2025
  inline_prompt: PromptData,
1045
2026
  function_type: FunctionTypeEnum.optional(),
1046
- name: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
2027
+ name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
1047
2028
  })
1048
2029
  ]);
1049
- var FunctionObjectType = _zod.z.enum([
2030
+ var FunctionObjectType = _v3.z.enum([
1050
2031
  "prompt",
1051
2032
  "tool",
1052
2033
  "scorer",
1053
2034
  "task",
1054
2035
  "agent"
1055
2036
  ]);
1056
- var FunctionOutputType = _zod.z.enum(["completion", "score", "any"]);
1057
- var GitMetadataSettings = _zod.z.object({
1058
- collect: _zod.z.enum(["all", "none", "some"]),
1059
- fields: _zod.z.array(
1060
- _zod.z.enum([
2037
+ var FunctionOutputType = _v3.z.enum(["completion", "score", "any"]);
2038
+ var GitMetadataSettings = _v3.z.object({
2039
+ collect: _v3.z.enum(["all", "none", "some"]),
2040
+ fields: _v3.z.array(
2041
+ _v3.z.enum([
1061
2042
  "commit",
1062
2043
  "branch",
1063
2044
  "tag",
@@ -1070,49 +2051,49 @@ var GitMetadataSettings = _zod.z.object({
1070
2051
  ])
1071
2052
  ).optional()
1072
2053
  });
1073
- var Group = _zod.z.object({
1074
- id: _zod.z.string().uuid(),
1075
- org_id: _zod.z.string().uuid(),
1076
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1077
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1078
- name: _zod.z.string(),
1079
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1080
- deleted_at: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1081
- member_users: _zod.z.union([_zod.z.array(_zod.z.string().uuid()), _zod.z.null()]).optional(),
1082
- member_groups: _zod.z.union([_zod.z.array(_zod.z.string().uuid()), _zod.z.null()]).optional()
2054
+ var Group = _v3.z.object({
2055
+ id: _v3.z.string().uuid(),
2056
+ org_id: _v3.z.string().uuid(),
2057
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2058
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2059
+ name: _v3.z.string(),
2060
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2061
+ deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2062
+ member_users: _v3.z.union([_v3.z.array(_v3.z.string().uuid()), _v3.z.null()]).optional(),
2063
+ member_groups: _v3.z.union([_v3.z.array(_v3.z.string().uuid()), _v3.z.null()]).optional()
1083
2064
  });
1084
- var IfExists = _zod.z.enum(["error", "ignore", "replace"]);
1085
- var InvokeParent = _zod.z.union([
1086
- _zod.z.object({
1087
- object_type: _zod.z.enum(["project_logs", "experiment", "playground_logs"]),
1088
- object_id: _zod.z.string(),
1089
- row_ids: _zod.z.union([
1090
- _zod.z.object({
1091
- id: _zod.z.string(),
1092
- span_id: _zod.z.string(),
1093
- root_span_id: _zod.z.string()
2065
+ var IfExists = _v3.z.enum(["error", "ignore", "replace"]);
2066
+ var InvokeParent = _v3.z.union([
2067
+ _v3.z.object({
2068
+ object_type: _v3.z.enum(["project_logs", "experiment", "playground_logs"]),
2069
+ object_id: _v3.z.string(),
2070
+ row_ids: _v3.z.union([
2071
+ _v3.z.object({
2072
+ id: _v3.z.string(),
2073
+ span_id: _v3.z.string(),
2074
+ root_span_id: _v3.z.string()
1094
2075
  }),
1095
- _zod.z.null()
2076
+ _v3.z.null()
1096
2077
  ]).optional(),
1097
- propagated_event: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.null()]).optional()
2078
+ propagated_event: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional()
1098
2079
  }),
1099
- _zod.z.string()
2080
+ _v3.z.string()
1100
2081
  ]);
1101
- var StreamingMode = _zod.z.union([_zod.z.enum(["auto", "parallel"]), _zod.z.null()]);
2082
+ var StreamingMode = _v3.z.union([_v3.z.enum(["auto", "parallel"]), _v3.z.null()]);
1102
2083
  var InvokeFunction = FunctionId.and(
1103
- _zod.z.object({
1104
- input: _zod.z.unknown(),
1105
- expected: _zod.z.unknown(),
1106
- metadata: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.null()]),
1107
- tags: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]),
1108
- messages: _zod.z.array(ChatCompletionMessageParam),
2084
+ _v3.z.object({
2085
+ input: _v3.z.unknown(),
2086
+ expected: _v3.z.unknown(),
2087
+ metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]),
2088
+ tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]),
2089
+ messages: _v3.z.array(ChatCompletionMessageParam),
1109
2090
  parent: InvokeParent,
1110
- stream: _zod.z.union([_zod.z.boolean(), _zod.z.null()]),
2091
+ stream: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
1111
2092
  mode: StreamingMode,
1112
- strict: _zod.z.union([_zod.z.boolean(), _zod.z.null()])
2093
+ strict: _v3.z.union([_v3.z.boolean(), _v3.z.null()])
1113
2094
  }).partial()
1114
2095
  );
1115
- var MessageRole = _zod.z.enum([
2096
+ var MessageRole = _v3.z.enum([
1116
2097
  "system",
1117
2098
  "user",
1118
2099
  "assistant",
@@ -1121,8 +2102,8 @@ var MessageRole = _zod.z.enum([
1121
2102
  "model",
1122
2103
  "developer"
1123
2104
  ]);
1124
- var ObjectReference = _zod.z.object({
1125
- object_type: _zod.z.enum([
2105
+ var ObjectReference = _v3.z.object({
2106
+ object_type: _v3.z.enum([
1126
2107
  "project_logs",
1127
2108
  "experiment",
1128
2109
  "dataset",
@@ -1130,146 +2111,146 @@ var ObjectReference = _zod.z.object({
1130
2111
  "function",
1131
2112
  "prompt_session"
1132
2113
  ]),
1133
- object_id: _zod.z.string().uuid(),
1134
- id: _zod.z.string(),
1135
- _xact_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1136
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
2114
+ object_id: _v3.z.string().uuid(),
2115
+ id: _v3.z.string(),
2116
+ _xact_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2117
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
1137
2118
  });
1138
- var OnlineScoreConfig = _zod.z.union([
1139
- _zod.z.object({
1140
- sampling_rate: _zod.z.number().gte(0).lte(1),
1141
- scorers: _zod.z.array(SavedFunctionId),
1142
- btql_filter: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1143
- apply_to_root_span: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional(),
1144
- apply_to_span_names: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional(),
1145
- skip_logging: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional()
2119
+ var OnlineScoreConfig = _v3.z.union([
2120
+ _v3.z.object({
2121
+ sampling_rate: _v3.z.number().gte(0).lte(1),
2122
+ scorers: _v3.z.array(SavedFunctionId),
2123
+ btql_filter: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2124
+ apply_to_root_span: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
2125
+ apply_to_span_names: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
2126
+ skip_logging: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
1146
2127
  }),
1147
- _zod.z.null()
2128
+ _v3.z.null()
1148
2129
  ]);
1149
- var Organization = _zod.z.object({
1150
- id: _zod.z.string().uuid(),
1151
- name: _zod.z.string(),
1152
- api_url: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1153
- is_universal_api: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional(),
1154
- proxy_url: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1155
- realtime_url: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1156
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
2130
+ var Organization = _v3.z.object({
2131
+ id: _v3.z.string().uuid(),
2132
+ name: _v3.z.string(),
2133
+ api_url: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2134
+ is_universal_api: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
2135
+ proxy_url: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2136
+ realtime_url: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2137
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
1157
2138
  });
1158
- var ProjectSettings = _zod.z.union([
1159
- _zod.z.object({
1160
- comparison_key: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1161
- baseline_experiment_id: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1162
- spanFieldOrder: _zod.z.union([
1163
- _zod.z.array(
1164
- _zod.z.object({
1165
- object_type: _zod.z.string(),
1166
- column_id: _zod.z.string(),
1167
- position: _zod.z.string(),
1168
- layout: _zod.z.union([_zod.z.literal("full"), _zod.z.literal("two_column"), _zod.z.null()]).optional()
2139
+ var ProjectSettings = _v3.z.union([
2140
+ _v3.z.object({
2141
+ comparison_key: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2142
+ baseline_experiment_id: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2143
+ spanFieldOrder: _v3.z.union([
2144
+ _v3.z.array(
2145
+ _v3.z.object({
2146
+ object_type: _v3.z.string(),
2147
+ column_id: _v3.z.string(),
2148
+ position: _v3.z.string(),
2149
+ layout: _v3.z.union([_v3.z.literal("full"), _v3.z.literal("two_column"), _v3.z.null()]).optional()
1169
2150
  })
1170
2151
  ),
1171
- _zod.z.null()
2152
+ _v3.z.null()
1172
2153
  ]),
1173
- remote_eval_sources: _zod.z.union([
1174
- _zod.z.array(
1175
- _zod.z.object({
1176
- url: _zod.z.string(),
1177
- name: _zod.z.string(),
1178
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
2154
+ remote_eval_sources: _v3.z.union([
2155
+ _v3.z.array(
2156
+ _v3.z.object({
2157
+ url: _v3.z.string(),
2158
+ name: _v3.z.string(),
2159
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
1179
2160
  })
1180
2161
  ),
1181
- _zod.z.null()
2162
+ _v3.z.null()
1182
2163
  ])
1183
2164
  }).partial(),
1184
- _zod.z.null()
2165
+ _v3.z.null()
1185
2166
  ]);
1186
- var Project = _zod.z.object({
1187
- id: _zod.z.string().uuid(),
1188
- org_id: _zod.z.string().uuid(),
1189
- name: _zod.z.string(),
1190
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1191
- deleted_at: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1192
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
2167
+ var Project = _v3.z.object({
2168
+ id: _v3.z.string().uuid(),
2169
+ org_id: _v3.z.string().uuid(),
2170
+ name: _v3.z.string(),
2171
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2172
+ deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2173
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1193
2174
  settings: ProjectSettings.optional()
1194
2175
  });
1195
- var RetentionObjectType = _zod.z.enum([
2176
+ var RetentionObjectType = _v3.z.enum([
1196
2177
  "project_logs",
1197
2178
  "experiment",
1198
2179
  "dataset"
1199
2180
  ]);
1200
- var ProjectAutomation = _zod.z.object({
1201
- id: _zod.z.string().uuid(),
1202
- project_id: _zod.z.string().uuid(),
1203
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1204
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1205
- name: _zod.z.string(),
1206
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1207
- config: _zod.z.union([
1208
- _zod.z.object({
1209
- event_type: _zod.z.literal("logs"),
1210
- btql_filter: _zod.z.string(),
1211
- interval_seconds: _zod.z.number().gte(1).lte(2592e3),
1212
- action: _zod.z.object({ type: _zod.z.literal("webhook"), url: _zod.z.string() })
2181
+ var ProjectAutomation = _v3.z.object({
2182
+ id: _v3.z.string().uuid(),
2183
+ project_id: _v3.z.string().uuid(),
2184
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2185
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2186
+ name: _v3.z.string(),
2187
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2188
+ config: _v3.z.union([
2189
+ _v3.z.object({
2190
+ event_type: _v3.z.literal("logs"),
2191
+ btql_filter: _v3.z.string(),
2192
+ interval_seconds: _v3.z.number().gte(1).lte(2592e3),
2193
+ action: _v3.z.object({ type: _v3.z.literal("webhook"), url: _v3.z.string() })
1213
2194
  }),
1214
- _zod.z.object({
1215
- event_type: _zod.z.literal("btql_export"),
1216
- export_definition: _zod.z.union([
1217
- _zod.z.object({ type: _zod.z.literal("log_traces") }),
1218
- _zod.z.object({ type: _zod.z.literal("log_spans") }),
1219
- _zod.z.object({ type: _zod.z.literal("btql_query"), btql_query: _zod.z.string() })
2195
+ _v3.z.object({
2196
+ event_type: _v3.z.literal("btql_export"),
2197
+ export_definition: _v3.z.union([
2198
+ _v3.z.object({ type: _v3.z.literal("log_traces") }),
2199
+ _v3.z.object({ type: _v3.z.literal("log_spans") }),
2200
+ _v3.z.object({ type: _v3.z.literal("btql_query"), btql_query: _v3.z.string() })
1220
2201
  ]),
1221
- export_path: _zod.z.string(),
1222
- format: _zod.z.enum(["jsonl", "parquet"]),
1223
- interval_seconds: _zod.z.number().gte(1).lte(2592e3),
1224
- credentials: _zod.z.object({
1225
- type: _zod.z.literal("aws_iam"),
1226
- role_arn: _zod.z.string(),
1227
- external_id: _zod.z.string()
2202
+ export_path: _v3.z.string(),
2203
+ format: _v3.z.enum(["jsonl", "parquet"]),
2204
+ interval_seconds: _v3.z.number().gte(1).lte(2592e3),
2205
+ credentials: _v3.z.object({
2206
+ type: _v3.z.literal("aws_iam"),
2207
+ role_arn: _v3.z.string(),
2208
+ external_id: _v3.z.string()
1228
2209
  }),
1229
- batch_size: _zod.z.union([_zod.z.number(), _zod.z.null()]).optional()
2210
+ batch_size: _v3.z.union([_v3.z.number(), _v3.z.null()]).optional()
1230
2211
  }),
1231
- _zod.z.object({
1232
- event_type: _zod.z.literal("retention"),
2212
+ _v3.z.object({
2213
+ event_type: _v3.z.literal("retention"),
1233
2214
  object_type: RetentionObjectType,
1234
- retention_days: _zod.z.number().gte(0)
2215
+ retention_days: _v3.z.number().gte(0)
1235
2216
  })
1236
2217
  ])
1237
2218
  });
1238
- var ProjectLogsEvent = _zod.z.object({
1239
- id: _zod.z.string(),
1240
- _xact_id: _zod.z.string(),
1241
- _pagination_key: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1242
- created: _zod.z.string().datetime({ offset: true }),
1243
- org_id: _zod.z.string().uuid(),
1244
- project_id: _zod.z.string().uuid(),
1245
- log_id: _zod.z.literal("g"),
1246
- input: _zod.z.unknown().optional(),
1247
- output: _zod.z.unknown().optional(),
1248
- expected: _zod.z.unknown().optional(),
1249
- error: _zod.z.unknown().optional(),
1250
- scores: _zod.z.union([_zod.z.record(_zod.z.union([_zod.z.number(), _zod.z.null()])), _zod.z.null()]).optional(),
1251
- metadata: _zod.z.union([
1252
- _zod.z.object({ model: _zod.z.union([_zod.z.string(), _zod.z.null()]) }).partial().passthrough(),
1253
- _zod.z.null()
2219
+ var ProjectLogsEvent = _v3.z.object({
2220
+ id: _v3.z.string(),
2221
+ _xact_id: _v3.z.string(),
2222
+ _pagination_key: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2223
+ created: _v3.z.string().datetime({ offset: true }),
2224
+ org_id: _v3.z.string().uuid(),
2225
+ project_id: _v3.z.string().uuid(),
2226
+ log_id: _v3.z.literal("g"),
2227
+ input: _v3.z.unknown().optional(),
2228
+ output: _v3.z.unknown().optional(),
2229
+ expected: _v3.z.unknown().optional(),
2230
+ error: _v3.z.unknown().optional(),
2231
+ scores: _v3.z.union([_v3.z.record(_v3.z.union([_v3.z.number(), _v3.z.null()])), _v3.z.null()]).optional(),
2232
+ metadata: _v3.z.union([
2233
+ _v3.z.object({ model: _v3.z.union([_v3.z.string(), _v3.z.null()]) }).partial().passthrough(),
2234
+ _v3.z.null()
1254
2235
  ]).optional(),
1255
- tags: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional(),
1256
- metrics: _zod.z.union([_zod.z.record(_zod.z.number()), _zod.z.null()]).optional(),
1257
- context: _zod.z.union([
1258
- _zod.z.object({
1259
- caller_functionname: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1260
- caller_filename: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1261
- caller_lineno: _zod.z.union([_zod.z.number(), _zod.z.null()])
2236
+ tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
2237
+ metrics: _v3.z.union([_v3.z.record(_v3.z.number()), _v3.z.null()]).optional(),
2238
+ context: _v3.z.union([
2239
+ _v3.z.object({
2240
+ caller_functionname: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2241
+ caller_filename: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2242
+ caller_lineno: _v3.z.union([_v3.z.number(), _v3.z.null()])
1262
2243
  }).partial().passthrough(),
1263
- _zod.z.null()
2244
+ _v3.z.null()
1264
2245
  ]).optional(),
1265
- span_id: _zod.z.string(),
1266
- span_parents: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional(),
1267
- root_span_id: _zod.z.string(),
1268
- is_root: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional(),
2246
+ span_id: _v3.z.string(),
2247
+ span_parents: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
2248
+ root_span_id: _v3.z.string(),
2249
+ is_root: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
1269
2250
  span_attributes: SpanAttributes.optional(),
1270
2251
  origin: ObjectReferenceNullish.optional()
1271
2252
  });
1272
- var ProjectScoreType = _zod.z.enum([
2253
+ var ProjectScoreType = _v3.z.enum([
1273
2254
  "slider",
1274
2255
  "categorical",
1275
2256
  "weighted",
@@ -1278,172 +2259,172 @@ var ProjectScoreType = _zod.z.enum([
1278
2259
  "online",
1279
2260
  "free-form"
1280
2261
  ]);
1281
- var ProjectScoreCategory = _zod.z.object({
1282
- name: _zod.z.string(),
1283
- value: _zod.z.number()
2262
+ var ProjectScoreCategory = _v3.z.object({
2263
+ name: _v3.z.string(),
2264
+ value: _v3.z.number()
1284
2265
  });
1285
- var ProjectScoreCategories = _zod.z.union([
1286
- _zod.z.array(ProjectScoreCategory),
1287
- _zod.z.record(_zod.z.number()),
1288
- _zod.z.array(_zod.z.string()),
1289
- _zod.z.null()
2266
+ var ProjectScoreCategories = _v3.z.union([
2267
+ _v3.z.array(ProjectScoreCategory),
2268
+ _v3.z.record(_v3.z.number()),
2269
+ _v3.z.array(_v3.z.string()),
2270
+ _v3.z.null()
1290
2271
  ]);
1291
- var ProjectScoreConfig = _zod.z.union([
1292
- _zod.z.object({
1293
- multi_select: _zod.z.union([_zod.z.boolean(), _zod.z.null()]),
1294
- destination: _zod.z.union([_zod.z.string(), _zod.z.null()]),
2272
+ var ProjectScoreConfig = _v3.z.union([
2273
+ _v3.z.object({
2274
+ multi_select: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
2275
+ destination: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1295
2276
  online: OnlineScoreConfig
1296
2277
  }).partial(),
1297
- _zod.z.null()
2278
+ _v3.z.null()
1298
2279
  ]);
1299
- var ProjectScore = _zod.z.object({
1300
- id: _zod.z.string().uuid(),
1301
- project_id: _zod.z.string().uuid(),
1302
- user_id: _zod.z.string().uuid(),
1303
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1304
- name: _zod.z.string(),
1305
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
2280
+ var ProjectScore = _v3.z.object({
2281
+ id: _v3.z.string().uuid(),
2282
+ project_id: _v3.z.string().uuid(),
2283
+ user_id: _v3.z.string().uuid(),
2284
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2285
+ name: _v3.z.string(),
2286
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1306
2287
  score_type: ProjectScoreType,
1307
2288
  categories: ProjectScoreCategories.optional(),
1308
2289
  config: ProjectScoreConfig.optional(),
1309
- position: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
2290
+ position: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
1310
2291
  });
1311
- var ProjectTag = _zod.z.object({
1312
- id: _zod.z.string().uuid(),
1313
- project_id: _zod.z.string().uuid(),
1314
- user_id: _zod.z.string().uuid(),
1315
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1316
- name: _zod.z.string(),
1317
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1318
- color: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1319
- position: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
2292
+ var ProjectTag = _v3.z.object({
2293
+ id: _v3.z.string().uuid(),
2294
+ project_id: _v3.z.string().uuid(),
2295
+ user_id: _v3.z.string().uuid(),
2296
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2297
+ name: _v3.z.string(),
2298
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2299
+ color: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2300
+ position: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
1320
2301
  });
1321
- var Prompt = _zod.z.object({
1322
- id: _zod.z.string().uuid(),
1323
- _xact_id: _zod.z.string(),
1324
- project_id: _zod.z.string().uuid(),
1325
- log_id: _zod.z.literal("p"),
1326
- org_id: _zod.z.string().uuid(),
1327
- name: _zod.z.string(),
1328
- slug: _zod.z.string(),
1329
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1330
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
2302
+ var Prompt = _v3.z.object({
2303
+ id: _v3.z.string().uuid(),
2304
+ _xact_id: _v3.z.string(),
2305
+ project_id: _v3.z.string().uuid(),
2306
+ log_id: _v3.z.literal("p"),
2307
+ org_id: _v3.z.string().uuid(),
2308
+ name: _v3.z.string(),
2309
+ slug: _v3.z.string(),
2310
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2311
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1331
2312
  prompt_data: PromptDataNullish.optional(),
1332
- tags: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional(),
1333
- metadata: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.null()]).optional(),
2313
+ tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
2314
+ metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional(),
1334
2315
  function_type: FunctionTypeEnumNullish.optional()
1335
2316
  });
1336
- var PromptOptions = _zod.z.object({ model: _zod.z.string(), params: ModelParams, position: _zod.z.string() }).partial();
1337
- var PromptSessionEvent = _zod.z.object({
1338
- id: _zod.z.string(),
1339
- _xact_id: _zod.z.string(),
1340
- created: _zod.z.string().datetime({ offset: true }),
1341
- _pagination_key: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1342
- project_id: _zod.z.string().uuid(),
1343
- prompt_session_id: _zod.z.string().uuid(),
1344
- prompt_session_data: _zod.z.unknown().optional(),
1345
- prompt_data: _zod.z.unknown().optional(),
1346
- function_data: _zod.z.unknown().optional(),
2317
+ var PromptOptions = _v3.z.object({ model: _v3.z.string(), params: ModelParams, position: _v3.z.string() }).partial();
2318
+ var PromptSessionEvent = _v3.z.object({
2319
+ id: _v3.z.string(),
2320
+ _xact_id: _v3.z.string(),
2321
+ created: _v3.z.string().datetime({ offset: true }),
2322
+ _pagination_key: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2323
+ project_id: _v3.z.string().uuid(),
2324
+ prompt_session_id: _v3.z.string().uuid(),
2325
+ prompt_session_data: _v3.z.unknown().optional(),
2326
+ prompt_data: _v3.z.unknown().optional(),
2327
+ function_data: _v3.z.unknown().optional(),
1347
2328
  function_type: FunctionTypeEnumNullish.optional(),
1348
- object_data: _zod.z.unknown().optional(),
1349
- completion: _zod.z.unknown().optional(),
1350
- tags: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional()
2329
+ object_data: _v3.z.unknown().optional(),
2330
+ completion: _v3.z.unknown().optional(),
2331
+ tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional()
1351
2332
  });
1352
- var ResponseFormat = _zod.z.union([
1353
- _zod.z.object({ type: _zod.z.literal("json_object") }),
1354
- _zod.z.object({
1355
- type: _zod.z.literal("json_schema"),
2333
+ var ResponseFormat = _v3.z.union([
2334
+ _v3.z.object({ type: _v3.z.literal("json_object") }),
2335
+ _v3.z.object({
2336
+ type: _v3.z.literal("json_schema"),
1356
2337
  json_schema: ResponseFormatJsonSchema
1357
2338
  }),
1358
- _zod.z.object({ type: _zod.z.literal("text") })
2339
+ _v3.z.object({ type: _v3.z.literal("text") })
1359
2340
  ]);
1360
- var Role = _zod.z.object({
1361
- id: _zod.z.string().uuid(),
1362
- org_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1363
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1364
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1365
- name: _zod.z.string(),
1366
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1367
- deleted_at: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1368
- member_permissions: _zod.z.union([
1369
- _zod.z.array(
1370
- _zod.z.object({
2341
+ var Role = _v3.z.object({
2342
+ id: _v3.z.string().uuid(),
2343
+ org_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2344
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2345
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2346
+ name: _v3.z.string(),
2347
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2348
+ deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2349
+ member_permissions: _v3.z.union([
2350
+ _v3.z.array(
2351
+ _v3.z.object({
1371
2352
  permission: Permission,
1372
2353
  restrict_object_type: AclObjectType.optional()
1373
2354
  })
1374
2355
  ),
1375
- _zod.z.null()
2356
+ _v3.z.null()
1376
2357
  ]).optional(),
1377
- member_roles: _zod.z.union([_zod.z.array(_zod.z.string().uuid()), _zod.z.null()]).optional()
2358
+ member_roles: _v3.z.union([_v3.z.array(_v3.z.string().uuid()), _v3.z.null()]).optional()
1378
2359
  });
1379
- var RunEval = _zod.z.object({
1380
- project_id: _zod.z.string(),
1381
- data: _zod.z.union([
1382
- _zod.z.object({
1383
- dataset_id: _zod.z.string(),
1384
- _internal_btql: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.null()]).optional()
2360
+ var RunEval = _v3.z.object({
2361
+ project_id: _v3.z.string(),
2362
+ data: _v3.z.union([
2363
+ _v3.z.object({
2364
+ dataset_id: _v3.z.string(),
2365
+ _internal_btql: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional()
1385
2366
  }),
1386
- _zod.z.object({
1387
- project_name: _zod.z.string(),
1388
- dataset_name: _zod.z.string(),
1389
- _internal_btql: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.null()]).optional()
2367
+ _v3.z.object({
2368
+ project_name: _v3.z.string(),
2369
+ dataset_name: _v3.z.string(),
2370
+ _internal_btql: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional()
1390
2371
  }),
1391
- _zod.z.object({ data: _zod.z.array(_zod.z.unknown()) })
2372
+ _v3.z.object({ data: _v3.z.array(_v3.z.unknown()) })
1392
2373
  ]),
1393
- task: FunctionId.and(_zod.z.unknown()),
1394
- scores: _zod.z.array(FunctionId),
1395
- experiment_name: _zod.z.string().optional(),
1396
- metadata: _zod.z.object({}).partial().passthrough().optional(),
1397
- parent: InvokeParent.and(_zod.z.unknown()).optional(),
1398
- stream: _zod.z.boolean().optional(),
1399
- trial_count: _zod.z.union([_zod.z.number(), _zod.z.null()]).optional(),
1400
- is_public: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional(),
1401
- timeout: _zod.z.union([_zod.z.number(), _zod.z.null()]).optional(),
1402
- max_concurrency: _zod.z.union([_zod.z.number(), _zod.z.null()]).optional().default(10),
1403
- base_experiment_name: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1404
- base_experiment_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
2374
+ task: FunctionId.and(_v3.z.unknown()),
2375
+ scores: _v3.z.array(FunctionId),
2376
+ experiment_name: _v3.z.string().optional(),
2377
+ metadata: _v3.z.object({}).partial().passthrough().optional(),
2378
+ parent: InvokeParent.and(_v3.z.unknown()).optional(),
2379
+ stream: _v3.z.boolean().optional(),
2380
+ trial_count: _v3.z.union([_v3.z.number(), _v3.z.null()]).optional(),
2381
+ is_public: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
2382
+ timeout: _v3.z.union([_v3.z.number(), _v3.z.null()]).optional(),
2383
+ max_concurrency: _v3.z.union([_v3.z.number(), _v3.z.null()]).optional().default(10),
2384
+ base_experiment_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2385
+ base_experiment_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1405
2386
  git_metadata_settings: GitMetadataSettings.and(
1406
- _zod.z.union([_zod.z.object({}).partial(), _zod.z.null()])
2387
+ _v3.z.union([_v3.z.object({}).partial(), _v3.z.null()])
1407
2388
  ).optional(),
1408
- repo_info: RepoInfo.and(_zod.z.unknown()).optional(),
1409
- strict: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional(),
1410
- stop_token: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1411
- extra_messages: _zod.z.string().optional(),
1412
- tags: _zod.z.array(_zod.z.string()).optional()
2389
+ repo_info: RepoInfo.and(_v3.z.unknown()).optional(),
2390
+ strict: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
2391
+ stop_token: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2392
+ extra_messages: _v3.z.string().optional(),
2393
+ tags: _v3.z.array(_v3.z.string()).optional()
1413
2394
  });
1414
- var ServiceToken = _zod.z.object({
1415
- id: _zod.z.string().uuid(),
1416
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1417
- name: _zod.z.string(),
1418
- preview_name: _zod.z.string(),
1419
- service_account_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1420
- service_account_email: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1421
- service_account_name: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1422
- org_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
2395
+ var ServiceToken = _v3.z.object({
2396
+ id: _v3.z.string().uuid(),
2397
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2398
+ name: _v3.z.string(),
2399
+ preview_name: _v3.z.string(),
2400
+ service_account_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2401
+ service_account_email: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2402
+ service_account_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2403
+ org_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
1423
2404
  });
1424
- var SpanIFrame = _zod.z.object({
1425
- id: _zod.z.string().uuid(),
1426
- project_id: _zod.z.string().uuid(),
1427
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1428
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1429
- deleted_at: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1430
- name: _zod.z.string(),
1431
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1432
- url: _zod.z.string(),
1433
- post_message: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional()
2405
+ var SpanIFrame = _v3.z.object({
2406
+ id: _v3.z.string().uuid(),
2407
+ project_id: _v3.z.string().uuid(),
2408
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2409
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2410
+ deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2411
+ name: _v3.z.string(),
2412
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2413
+ url: _v3.z.string(),
2414
+ post_message: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
1434
2415
  });
1435
- var SSEConsoleEventData = _zod.z.object({
1436
- stream: _zod.z.enum(["stderr", "stdout"]),
1437
- message: _zod.z.string()
2416
+ var SSEConsoleEventData = _v3.z.object({
2417
+ stream: _v3.z.enum(["stderr", "stdout"]),
2418
+ message: _v3.z.string()
1438
2419
  });
1439
- var SSEProgressEventData = _zod.z.object({
1440
- id: _zod.z.string(),
2420
+ var SSEProgressEventData = _v3.z.object({
2421
+ id: _v3.z.string(),
1441
2422
  object_type: FunctionObjectType,
1442
- origin: ObjectReferenceNullish.and(_zod.z.unknown()).optional(),
2423
+ origin: ObjectReferenceNullish.and(_v3.z.unknown()).optional(),
1443
2424
  format: FunctionFormat,
1444
2425
  output_type: FunctionOutputType,
1445
- name: _zod.z.string(),
1446
- event: _zod.z.enum([
2426
+ name: _v3.z.string(),
2427
+ event: _v3.z.enum([
1447
2428
  "reasoning_delta",
1448
2429
  "text_delta",
1449
2430
  "json_delta",
@@ -1453,110 +2434,110 @@ var SSEProgressEventData = _zod.z.object({
1453
2434
  "done",
1454
2435
  "progress"
1455
2436
  ]),
1456
- data: _zod.z.string()
2437
+ data: _v3.z.string()
1457
2438
  });
1458
- var ToolFunctionDefinition = _zod.z.object({
1459
- type: _zod.z.literal("function"),
1460
- function: _zod.z.object({
1461
- name: _zod.z.string(),
1462
- description: _zod.z.string().optional(),
1463
- parameters: _zod.z.object({}).partial().passthrough().optional(),
1464
- strict: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional()
2439
+ var ToolFunctionDefinition = _v3.z.object({
2440
+ type: _v3.z.literal("function"),
2441
+ function: _v3.z.object({
2442
+ name: _v3.z.string(),
2443
+ description: _v3.z.string().optional(),
2444
+ parameters: _v3.z.object({}).partial().passthrough().optional(),
2445
+ strict: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
1465
2446
  })
1466
2447
  });
1467
- var User = _zod.z.object({
1468
- id: _zod.z.string().uuid(),
1469
- given_name: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1470
- family_name: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1471
- email: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1472
- avatar_url: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1473
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
2448
+ var User = _v3.z.object({
2449
+ id: _v3.z.string().uuid(),
2450
+ given_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2451
+ family_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2452
+ email: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2453
+ avatar_url: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2454
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
1474
2455
  });
1475
- var ViewDataSearch = _zod.z.union([
1476
- _zod.z.object({
1477
- filter: _zod.z.union([_zod.z.array(_zod.z.unknown()), _zod.z.null()]),
1478
- tag: _zod.z.union([_zod.z.array(_zod.z.unknown()), _zod.z.null()]),
1479
- match: _zod.z.union([_zod.z.array(_zod.z.unknown()), _zod.z.null()]),
1480
- sort: _zod.z.union([_zod.z.array(_zod.z.unknown()), _zod.z.null()])
2456
+ var ViewDataSearch = _v3.z.union([
2457
+ _v3.z.object({
2458
+ filter: _v3.z.union([_v3.z.array(_v3.z.unknown()), _v3.z.null()]),
2459
+ tag: _v3.z.union([_v3.z.array(_v3.z.unknown()), _v3.z.null()]),
2460
+ match: _v3.z.union([_v3.z.array(_v3.z.unknown()), _v3.z.null()]),
2461
+ sort: _v3.z.union([_v3.z.array(_v3.z.unknown()), _v3.z.null()])
1481
2462
  }).partial(),
1482
- _zod.z.null()
2463
+ _v3.z.null()
1483
2464
  ]);
1484
- var ViewData = _zod.z.union([
1485
- _zod.z.object({ search: ViewDataSearch }).partial(),
1486
- _zod.z.null()
2465
+ var ViewData = _v3.z.union([
2466
+ _v3.z.object({ search: ViewDataSearch }).partial(),
2467
+ _v3.z.null()
1487
2468
  ]);
1488
- var ViewOptions = _zod.z.union([
1489
- _zod.z.object({
1490
- viewType: _zod.z.literal("monitor"),
1491
- options: _zod.z.object({
1492
- spanType: _zod.z.union([_zod.z.enum(["range", "frame"]), _zod.z.null()]),
1493
- rangeValue: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1494
- frameStart: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1495
- frameEnd: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1496
- tzUTC: _zod.z.union([_zod.z.boolean(), _zod.z.null()]),
1497
- chartVisibility: _zod.z.union([_zod.z.record(_zod.z.boolean()), _zod.z.null()]),
1498
- projectId: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1499
- type: _zod.z.union([_zod.z.enum(["project", "experiment"]), _zod.z.null()]),
1500
- groupBy: _zod.z.union([_zod.z.string(), _zod.z.null()])
2469
+ var ViewOptions = _v3.z.union([
2470
+ _v3.z.object({
2471
+ viewType: _v3.z.literal("monitor"),
2472
+ options: _v3.z.object({
2473
+ spanType: _v3.z.union([_v3.z.enum(["range", "frame"]), _v3.z.null()]),
2474
+ rangeValue: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2475
+ frameStart: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2476
+ frameEnd: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2477
+ tzUTC: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
2478
+ chartVisibility: _v3.z.union([_v3.z.record(_v3.z.boolean()), _v3.z.null()]),
2479
+ projectId: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2480
+ type: _v3.z.union([_v3.z.enum(["project", "experiment"]), _v3.z.null()]),
2481
+ groupBy: _v3.z.union([_v3.z.string(), _v3.z.null()])
1501
2482
  }).partial()
1502
2483
  }),
1503
- _zod.z.object({
1504
- columnVisibility: _zod.z.union([_zod.z.record(_zod.z.boolean()), _zod.z.null()]),
1505
- columnOrder: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]),
1506
- columnSizing: _zod.z.union([_zod.z.record(_zod.z.number()), _zod.z.null()]),
1507
- grouping: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1508
- rowHeight: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1509
- tallGroupRows: _zod.z.union([_zod.z.boolean(), _zod.z.null()]),
1510
- layout: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1511
- chartHeight: _zod.z.union([_zod.z.number(), _zod.z.null()]),
1512
- excludedMeasures: _zod.z.union([
1513
- _zod.z.array(
1514
- _zod.z.object({
1515
- type: _zod.z.enum(["none", "score", "metric", "metadata"]),
1516
- value: _zod.z.string()
2484
+ _v3.z.object({
2485
+ columnVisibility: _v3.z.union([_v3.z.record(_v3.z.boolean()), _v3.z.null()]),
2486
+ columnOrder: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]),
2487
+ columnSizing: _v3.z.union([_v3.z.record(_v3.z.number()), _v3.z.null()]),
2488
+ grouping: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2489
+ rowHeight: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2490
+ tallGroupRows: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
2491
+ layout: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2492
+ chartHeight: _v3.z.union([_v3.z.number(), _v3.z.null()]),
2493
+ excludedMeasures: _v3.z.union([
2494
+ _v3.z.array(
2495
+ _v3.z.object({
2496
+ type: _v3.z.enum(["none", "score", "metric", "metadata"]),
2497
+ value: _v3.z.string()
1517
2498
  })
1518
2499
  ),
1519
- _zod.z.null()
2500
+ _v3.z.null()
1520
2501
  ]),
1521
- yMetric: _zod.z.union([
1522
- _zod.z.object({
1523
- type: _zod.z.enum(["none", "score", "metric", "metadata"]),
1524
- value: _zod.z.string()
2502
+ yMetric: _v3.z.union([
2503
+ _v3.z.object({
2504
+ type: _v3.z.enum(["none", "score", "metric", "metadata"]),
2505
+ value: _v3.z.string()
1525
2506
  }),
1526
- _zod.z.null()
2507
+ _v3.z.null()
1527
2508
  ]),
1528
- xAxis: _zod.z.union([
1529
- _zod.z.object({
1530
- type: _zod.z.enum(["none", "score", "metric", "metadata"]),
1531
- value: _zod.z.string()
2509
+ xAxis: _v3.z.union([
2510
+ _v3.z.object({
2511
+ type: _v3.z.enum(["none", "score", "metric", "metadata"]),
2512
+ value: _v3.z.string()
1532
2513
  }),
1533
- _zod.z.null()
2514
+ _v3.z.null()
1534
2515
  ]),
1535
- symbolGrouping: _zod.z.union([
1536
- _zod.z.object({
1537
- type: _zod.z.enum(["none", "score", "metric", "metadata"]),
1538
- value: _zod.z.string()
2516
+ symbolGrouping: _v3.z.union([
2517
+ _v3.z.object({
2518
+ type: _v3.z.enum(["none", "score", "metric", "metadata"]),
2519
+ value: _v3.z.string()
1539
2520
  }),
1540
- _zod.z.null()
2521
+ _v3.z.null()
1541
2522
  ]),
1542
- xAxisAggregation: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1543
- chartAnnotations: _zod.z.union([
1544
- _zod.z.array(_zod.z.object({ id: _zod.z.string(), text: _zod.z.string() })),
1545
- _zod.z.null()
2523
+ xAxisAggregation: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2524
+ chartAnnotations: _v3.z.union([
2525
+ _v3.z.array(_v3.z.object({ id: _v3.z.string(), text: _v3.z.string() })),
2526
+ _v3.z.null()
1546
2527
  ]),
1547
- timeRangeFilter: _zod.z.union([
1548
- _zod.z.string(),
1549
- _zod.z.object({ from: _zod.z.string(), to: _zod.z.string() }),
1550
- _zod.z.null()
2528
+ timeRangeFilter: _v3.z.union([
2529
+ _v3.z.string(),
2530
+ _v3.z.object({ from: _v3.z.string(), to: _v3.z.string() }),
2531
+ _v3.z.null()
1551
2532
  ])
1552
2533
  }).partial(),
1553
- _zod.z.null()
2534
+ _v3.z.null()
1554
2535
  ]);
1555
- var View = _zod.z.object({
1556
- id: _zod.z.string().uuid(),
1557
- object_type: AclObjectType.and(_zod.z.string()),
1558
- object_id: _zod.z.string().uuid(),
1559
- view_type: _zod.z.enum([
2536
+ var View = _v3.z.object({
2537
+ id: _v3.z.string().uuid(),
2538
+ object_type: AclObjectType.and(_v3.z.string()),
2539
+ object_id: _v3.z.string().uuid(),
2540
+ view_type: _v3.z.enum([
1560
2541
  "projects",
1561
2542
  "experiments",
1562
2543
  "experiment",
@@ -1571,56 +2552,56 @@ var View = _zod.z.object({
1571
2552
  "agents",
1572
2553
  "monitor"
1573
2554
  ]),
1574
- name: _zod.z.string(),
1575
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
2555
+ name: _v3.z.string(),
2556
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1576
2557
  view_data: ViewData.optional(),
1577
2558
  options: ViewOptions.optional(),
1578
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1579
- deleted_at: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
2559
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2560
+ deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
1580
2561
  });
1581
2562
 
1582
2563
  // src/logger.ts
1583
2564
  var _functions = require('@vercel/functions');
1584
2565
  var _mustache = require('mustache'); var _mustache2 = _interopRequireDefault(_mustache);
1585
-
2566
+ var _zod = require('zod');
1586
2567
 
1587
2568
  // src/functions/stream.ts
1588
2569
 
1589
2570
 
1590
2571
  var _eventsourceparser = require('eventsource-parser');
1591
2572
 
1592
- var braintrustStreamChunkSchema = _zod.z.union([
1593
- _zod.z.object({
1594
- type: _zod.z.literal("text_delta"),
1595
- data: _zod.z.string()
2573
+ var braintrustStreamChunkSchema = _v3.z.union([
2574
+ _v3.z.object({
2575
+ type: _v3.z.literal("text_delta"),
2576
+ data: _v3.z.string()
1596
2577
  }),
1597
- _zod.z.object({
1598
- type: _zod.z.literal("reasoning_delta"),
1599
- data: _zod.z.string()
2578
+ _v3.z.object({
2579
+ type: _v3.z.literal("reasoning_delta"),
2580
+ data: _v3.z.string()
1600
2581
  }),
1601
- _zod.z.object({
1602
- type: _zod.z.literal("json_delta"),
1603
- data: _zod.z.string()
2582
+ _v3.z.object({
2583
+ type: _v3.z.literal("json_delta"),
2584
+ data: _v3.z.string()
1604
2585
  }),
1605
- _zod.z.object({
1606
- type: _zod.z.literal("error"),
1607
- data: _zod.z.string()
2586
+ _v3.z.object({
2587
+ type: _v3.z.literal("error"),
2588
+ data: _v3.z.string()
1608
2589
  }),
1609
- _zod.z.object({
1610
- type: _zod.z.literal("console"),
2590
+ _v3.z.object({
2591
+ type: _v3.z.literal("console"),
1611
2592
  data: SSEConsoleEventData
1612
2593
  }),
1613
- _zod.z.object({
1614
- type: _zod.z.literal("progress"),
2594
+ _v3.z.object({
2595
+ type: _v3.z.literal("progress"),
1615
2596
  data: SSEProgressEventData
1616
2597
  }),
1617
- _zod.z.object({
1618
- type: _zod.z.literal("start"),
1619
- data: _zod.z.string()
2598
+ _v3.z.object({
2599
+ type: _v3.z.literal("start"),
2600
+ data: _v3.z.string()
1620
2601
  }),
1621
- _zod.z.object({
1622
- type: _zod.z.literal("done"),
1623
- data: _zod.z.string()
2602
+ _v3.z.object({
2603
+ type: _v3.z.literal("done"),
2604
+ data: _v3.z.string()
1624
2605
  })
1625
2606
  ]);
1626
2607
  var BraintrustStream = class _BraintrustStream {
@@ -2206,12 +3187,11 @@ var InternalAbortError = class extends Error {
2206
3187
 
2207
3188
  // src/mustache-utils.ts
2208
3189
 
2209
-
2210
3190
  function lintTemplate(template, context) {
2211
3191
  const variables = getMustacheVars(template);
2212
3192
  for (const variable of variables) {
2213
3193
  const arrPathsReplaced = variable[1].replaceAll(/\.\d+/g, ".0");
2214
- const fieldExists = _core.getObjValueByPath.call(void 0, context, arrPathsReplaced.split(".")) !== void 0;
3194
+ const fieldExists = getObjValueByPath(context, arrPathsReplaced.split(".")) !== void 0;
2215
3195
  if (!fieldExists) {
2216
3196
  throw new Error(`Variable '${variable[1]}' does not exist.`);
2217
3197
  }
@@ -2222,13 +3202,12 @@ function getMustacheVars(prompt) {
2222
3202
  return _mustache2.default.parse(prompt).filter(
2223
3203
  (span) => span[0] === "name" || span[0] === "&"
2224
3204
  );
2225
- } catch (e3) {
3205
+ } catch (e5) {
2226
3206
  return [];
2227
3207
  }
2228
3208
  }
2229
3209
 
2230
3210
  // src/logger.ts
2231
-
2232
3211
  var BRAINTRUST_ATTACHMENT = BraintrustAttachmentReference.shape.type.value;
2233
3212
  var EXTERNAL_ATTACHMENT = ExternalAttachmentReference.shape.type.value;
2234
3213
  var BRAINTRUST_PARAMS = Object.keys(BraintrustModelParams.shape);
@@ -2289,7 +3268,7 @@ var NoopSpan = (_class4 = class {
2289
3268
  return this;
2290
3269
  }
2291
3270
  end(args) {
2292
- return _nullishCoalesce(_optionalChain([args, 'optionalAccess', _11 => _11.endTime]), () => ( getCurrentUnixTimestamp()));
3271
+ return _nullishCoalesce(_optionalChain([args, 'optionalAccess', _21 => _21.endTime]), () => ( getCurrentUnixTimestamp()));
2293
3272
  }
2294
3273
  async export() {
2295
3274
  return "";
@@ -2463,8 +3442,8 @@ var BraintrustState = (_class5 = class _BraintrustState {
2463
3442
  setFetch(fetch2) {
2464
3443
  this.loginParams.fetch = fetch2;
2465
3444
  this.fetch = fetch2;
2466
- _optionalChain([this, 'access', _12 => _12._apiConn, 'optionalAccess', _13 => _13.setFetch, 'call', _14 => _14(fetch2)]);
2467
- _optionalChain([this, 'access', _15 => _15._appConn, 'optionalAccess', _16 => _16.setFetch, 'call', _17 => _17(fetch2)]);
3445
+ _optionalChain([this, 'access', _22 => _22._apiConn, 'optionalAccess', _23 => _23.setFetch, 'call', _24 => _24(fetch2)]);
3446
+ _optionalChain([this, 'access', _25 => _25._appConn, 'optionalAccess', _26 => _26.setFetch, 'call', _27 => _27(fetch2)]);
2468
3447
  }
2469
3448
  setMaskingFunction(maskingFunction) {
2470
3449
  this.bgLogger().setMaskingFunction(maskingFunction);
@@ -2612,7 +3591,7 @@ var HTTPConnection = class _HTTPConnection {
2612
3591
  }
2613
3592
  async get(path3, params = void 0, config) {
2614
3593
  const { headers, ...rest } = config || {};
2615
- const url = new URL(_core._urljoin.call(void 0, this.base_url, path3));
3594
+ const url = new URL(_urljoin(this.base_url, path3));
2616
3595
  url.search = new URLSearchParams(
2617
3596
  params ? Object.entries(params).filter(([_, v]) => v !== void 0).flatMap(
2618
3597
  ([k, v]) => v !== void 0 ? typeof v === "string" ? [[k, v]] : v.map((x) => [k, x]) : []
@@ -2639,7 +3618,7 @@ var HTTPConnection = class _HTTPConnection {
2639
3618
  const this_base_url = this.base_url;
2640
3619
  const this_headers = this.headers;
2641
3620
  return await checkResponse(
2642
- await this_fetch(_core._urljoin.call(void 0, this_base_url, path3), {
3621
+ await this_fetch(_urljoin(this_base_url, path3), {
2643
3622
  method: "POST",
2644
3623
  headers: {
2645
3624
  Accept: "application/json",
@@ -2967,8 +3946,8 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
2967
3946
  source: inputSource
2968
3947
  }) {
2969
3948
  const source = _nullishCoalesce(inputSource, () => ( "external"));
2970
- if (!_core.VALID_SOURCES.includes(source)) {
2971
- throw new Error(`source must be one of ${_core.VALID_SOURCES}`);
3949
+ if (!VALID_SOURCES.includes(source)) {
3950
+ throw new Error(`source must be one of ${VALID_SOURCES}`);
2972
3951
  }
2973
3952
  if (isEmpty(scores) && isEmpty(expected) && isEmpty(tags) && isEmpty(comment)) {
2974
3953
  throw new Error(
@@ -2985,7 +3964,7 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
2985
3964
  updateEvent = Object.fromEntries(
2986
3965
  Object.entries(updateEvent).filter(([_, v]) => !isEmpty(v))
2987
3966
  );
2988
- const parentIds = async () => new (0, _core.SpanComponentsV3)({
3967
+ const parentIds = async () => new SpanComponentsV3({
2989
3968
  object_type: parentObjectType,
2990
3969
  object_id: await parentObjectId.get()
2991
3970
  }).objectIdFields();
@@ -2995,9 +3974,9 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
2995
3974
  id,
2996
3975
  ...updateEvent,
2997
3976
  ...await parentIds(),
2998
- [_core.AUDIT_SOURCE_FIELD]: source,
2999
- [_core.AUDIT_METADATA_FIELD]: metadata,
3000
- [_core.IS_MERGE_FIELD]: true
3977
+ [AUDIT_SOURCE_FIELD]: source,
3978
+ [AUDIT_METADATA_FIELD]: metadata,
3979
+ [IS_MERGE_FIELD]: true
3001
3980
  };
3002
3981
  });
3003
3982
  state.bgLogger().log([record]);
@@ -3016,8 +3995,8 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
3016
3995
  text: comment
3017
3996
  },
3018
3997
  ...await parentIds(),
3019
- [_core.AUDIT_SOURCE_FIELD]: source,
3020
- [_core.AUDIT_METADATA_FIELD]: metadata
3998
+ [AUDIT_SOURCE_FIELD]: source,
3999
+ [AUDIT_METADATA_FIELD]: metadata
3021
4000
  };
3022
4001
  });
3023
4002
  state.bgLogger().log([record]);
@@ -3036,7 +4015,7 @@ function updateSpanImpl({
3036
4015
  ...event
3037
4016
  })
3038
4017
  );
3039
- const parentIds = async () => new (0, _core.SpanComponentsV3)({
4018
+ const parentIds = async () => new SpanComponentsV3({
3040
4019
  object_type: parentObjectType,
3041
4020
  object_id: await parentObjectId.get()
3042
4021
  }).objectIdFields();
@@ -3044,7 +4023,7 @@ function updateSpanImpl({
3044
4023
  id,
3045
4024
  ...updateEvent,
3046
4025
  ...await parentIds(),
3047
- [_core.IS_MERGE_FIELD]: true
4026
+ [IS_MERGE_FIELD]: true
3048
4027
  }));
3049
4028
  state.bgLogger().log([record]);
3050
4029
  }
@@ -3059,15 +4038,15 @@ function spanComponentsToObjectIdLambda(state, components) {
3059
4038
  );
3060
4039
  }
3061
4040
  switch (components.data.object_type) {
3062
- case _core.SpanObjectTypeV3.EXPERIMENT:
4041
+ case 1 /* EXPERIMENT */:
3063
4042
  throw new Error(
3064
4043
  "Impossible: computeObjectMetadataArgs not supported for experiments"
3065
4044
  );
3066
- case _core.SpanObjectTypeV3.PLAYGROUND_LOGS:
4045
+ case 3 /* PLAYGROUND_LOGS */:
3067
4046
  throw new Error(
3068
4047
  "Impossible: computeObjectMetadataArgs not supported for prompt sessions"
3069
4048
  );
3070
- case _core.SpanObjectTypeV3.PROJECT_LOGS:
4049
+ case 2 /* PROJECT_LOGS */:
3071
4050
  return async () => (await computeLoggerMetadata(state, {
3072
4051
  ...components.data.compute_object_metadata_args
3073
4052
  })).project.id;
@@ -3096,9 +4075,9 @@ async function permalink(slug, opts) {
3096
4075
  if (slug === "") {
3097
4076
  return NOOP_SPAN_PERMALINK;
3098
4077
  }
3099
- const state = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _18 => _18.state]), () => ( _globalState));
4078
+ const state = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _28 => _28.state]), () => ( _globalState));
3100
4079
  const getOrgName = async () => {
3101
- if (_optionalChain([opts, 'optionalAccess', _19 => _19.orgName])) {
4080
+ if (_optionalChain([opts, 'optionalAccess', _29 => _29.orgName])) {
3102
4081
  return opts.orgName;
3103
4082
  }
3104
4083
  await state.login({});
@@ -3108,7 +4087,7 @@ async function permalink(slug, opts) {
3108
4087
  return state.orgName;
3109
4088
  };
3110
4089
  const getAppUrl = async () => {
3111
- if (_optionalChain([opts, 'optionalAccess', _20 => _20.appUrl])) {
4090
+ if (_optionalChain([opts, 'optionalAccess', _30 => _30.appUrl])) {
3112
4091
  return opts.appUrl;
3113
4092
  }
3114
4093
  await state.login({});
@@ -3118,8 +4097,8 @@ async function permalink(slug, opts) {
3118
4097
  return state.appUrl;
3119
4098
  };
3120
4099
  try {
3121
- const components = _core.SpanComponentsV3.fromStr(slug);
3122
- const object_type = _core.spanObjectTypeV3ToString.call(void 0, components.data.object_type);
4100
+ const components = SpanComponentsV3.fromStr(slug);
4101
+ const object_type = spanObjectTypeV3ToString(components.data.object_type);
3123
4102
  const [orgName, appUrl, object_id] = await Promise.all([
3124
4103
  getOrgName(),
3125
4104
  getAppUrl(),
@@ -3146,7 +4125,7 @@ function startSpanParentArgs(args) {
3146
4125
  if (args.parentSpanIds) {
3147
4126
  throw new Error("Cannot specify both parent and parentSpanIds");
3148
4127
  }
3149
- const parentComponents = _core.SpanComponentsV3.fromStr(args.parent);
4128
+ const parentComponents = SpanComponentsV3.fromStr(args.parent);
3150
4129
  if (args.parentObjectType !== parentComponents.data.object_type) {
3151
4130
  throw new Error(
3152
4131
  `Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
@@ -3219,7 +4198,7 @@ var Logger = (_class6 = class {
3219
4198
  return (async () => (await this.project).id)();
3220
4199
  }
3221
4200
  parentObjectType() {
3222
- return _core.SpanObjectTypeV3.PROJECT_LOGS;
4201
+ return 2 /* PROJECT_LOGS */;
3223
4202
  }
3224
4203
  /**
3225
4204
  * Log a single event. The event will be batched and uploaded behind the scenes if `logOptions.asyncFlush` is true.
@@ -3238,7 +4217,7 @@ var Logger = (_class6 = class {
3238
4217
  * @returns The `id` of the logged event.
3239
4218
  */
3240
4219
  log(event, options) {
3241
- if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _21 => _21.allowConcurrentWithSpans])) {
4220
+ if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _31 => _31.allowConcurrentWithSpans])) {
3242
4221
  throw new Error(
3243
4222
  "Cannot run toplevel `log` method while using spans. To log to the span, call `logger.traced` and then log with `span.log`"
3244
4223
  );
@@ -3306,14 +4285,14 @@ var Logger = (_class6 = class {
3306
4285
  state: this.state,
3307
4286
  ...startSpanParentArgs({
3308
4287
  state: this.state,
3309
- parent: _optionalChain([args, 'optionalAccess', _22 => _22.parent]),
4288
+ parent: _optionalChain([args, 'optionalAccess', _32 => _32.parent]),
3310
4289
  parentObjectType: this.parentObjectType(),
3311
4290
  parentObjectId: this.lazyId,
3312
4291
  parentComputeObjectMetadataArgs: this.computeMetadataArgs,
3313
- parentSpanIds: _optionalChain([args, 'optionalAccess', _23 => _23.parentSpanIds]),
3314
- propagatedEvent: _optionalChain([args, 'optionalAccess', _24 => _24.propagatedEvent])
4292
+ parentSpanIds: _optionalChain([args, 'optionalAccess', _33 => _33.parentSpanIds]),
4293
+ propagatedEvent: _optionalChain([args, 'optionalAccess', _34 => _34.propagatedEvent])
3315
4294
  }),
3316
- defaultRootType: _core.SpanTypeAttribute.TASK
4295
+ defaultRootType: "task" /* TASK */
3317
4296
  });
3318
4297
  }
3319
4298
  /**
@@ -3355,7 +4334,7 @@ var Logger = (_class6 = class {
3355
4334
  * See {@link Span.startSpan} for more details.
3356
4335
  */
3357
4336
  async export() {
3358
- return new (0, _core.SpanComponentsV3)({
4337
+ return new SpanComponentsV3({
3359
4338
  object_type: this.parentObjectType(),
3360
4339
  ...this.computeMetadataArgs && !this.lazyId.hasSucceeded ? { compute_object_metadata_args: this.computeMetadataArgs } : { object_id: await this.lazyId.get() }
3361
4340
  }).toStr();
@@ -3380,7 +4359,7 @@ function castLogger(logger, asyncFlush) {
3380
4359
  return logger;
3381
4360
  }
3382
4361
  function constructLogs3Data(items) {
3383
- return `{"rows": ${_core.constructJsonArray.call(void 0, items)}, "api_version": 2}`;
4362
+ return `{"rows": ${constructJsonArray(items)}, "api_version": 2}`;
3384
4363
  }
3385
4364
  function now() {
3386
4365
  return (/* @__PURE__ */ new Date()).getTime();
@@ -3497,7 +4476,7 @@ var HTTPBackgroundLogger = (_class7 = class _HTTPBackgroundLogger {
3497
4476
  this.queue.clear();
3498
4477
  return;
3499
4478
  }
3500
- const batchSize = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _25 => _25.batchSize]), () => ( this.defaultBatchSize));
4479
+ const batchSize = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _35 => _35.batchSize]), () => ( this.defaultBatchSize));
3501
4480
  const wrappedItems = this.queue.drain();
3502
4481
  const [allItems, attachments] = await this.unwrapLazyValues(wrappedItems);
3503
4482
  if (allItems.length === 0) {
@@ -3506,7 +4485,7 @@ var HTTPBackgroundLogger = (_class7 = class _HTTPBackgroundLogger {
3506
4485
  const allItemsStr = allItems.map(
3507
4486
  (bucket) => bucket.map((item) => JSON.stringify(item))
3508
4487
  );
3509
- const batchSets = _core.batchItems.call(void 0, {
4488
+ const batchSets = batchItems({
3510
4489
  items: allItemsStr,
3511
4490
  batchMaxNumItems: batchSize,
3512
4491
  batchMaxNumBytes: this.maxRequestSize / 2
@@ -3560,7 +4539,7 @@ var HTTPBackgroundLogger = (_class7 = class _HTTPBackgroundLogger {
3560
4539
  const items = await Promise.all(wrappedItems.map((x) => x.get()));
3561
4540
  const attachments = [];
3562
4541
  items.forEach((item) => extractAttachments(item, attachments));
3563
- let mergedItems = _core.mergeRowBatch.call(void 0, items);
4542
+ let mergedItems = mergeRowBatch(items);
3564
4543
  if (this.maskingFunction) {
3565
4544
  mergedItems = mergedItems.map(
3566
4545
  (batch) => batch.map((item) => {
@@ -3746,10 +4725,10 @@ Error: ${errorText}`;
3746
4725
  } catch (err) {
3747
4726
  if (err instanceof AggregateError) {
3748
4727
  for (const e of err.errors) {
3749
- _optionalChain([this, 'access', _26 => _26.onFlushError, 'optionalCall', _27 => _27(e)]);
4728
+ _optionalChain([this, 'access', _36 => _36.onFlushError, 'optionalCall', _37 => _37(e)]);
3750
4729
  }
3751
4730
  } else {
3752
- _optionalChain([this, 'access', _28 => _28.onFlushError, 'optionalCall', _29 => _29(err)]);
4731
+ _optionalChain([this, 'access', _38 => _38.onFlushError, 'optionalCall', _39 => _39(err)]);
3753
4732
  }
3754
4733
  this.activeFlushError = err;
3755
4734
  } finally {
@@ -3879,7 +4858,7 @@ function init(projectOrOptions, optionalOptions) {
3879
4858
  }
3880
4859
  };
3881
4860
  if (gitMetadataSettings) {
3882
- mergedGitMetadataSettings = _core.mergeGitMetadataSettings.call(void 0,
4861
+ mergedGitMetadataSettings = mergeGitMetadataSettings(
3883
4862
  mergedGitMetadataSettings,
3884
4863
  gitMetadataSettings
3885
4864
  );
@@ -4106,7 +5085,7 @@ async function loginToState(options = {}) {
4106
5085
  return state;
4107
5086
  } else {
4108
5087
  const resp = await checkResponse(
4109
- await fetch2(_core._urljoin.call(void 0, state.appUrl, `/api/apikey/login`), {
5088
+ await fetch2(_urljoin(state.appUrl, `/api/apikey/login`), {
4110
5089
  method: "POST",
4111
5090
  headers: {
4112
5091
  "Content-Type": "application/json",
@@ -4144,23 +5123,25 @@ async function loginToState(options = {}) {
4144
5123
  return state;
4145
5124
  }
4146
5125
  function currentExperiment(options) {
4147
- const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _30 => _30.state]), () => ( _globalState));
5126
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _40 => _40.state]), () => ( _globalState));
4148
5127
  return state.currentExperiment;
4149
5128
  }
4150
5129
  function currentLogger(options) {
4151
- const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _31 => _31.state]), () => ( _globalState));
4152
- return castLogger(state.currentLogger, _optionalChain([options, 'optionalAccess', _32 => _32.asyncFlush]));
5130
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _41 => _41.state]), () => ( _globalState));
5131
+ return castLogger(state.currentLogger, _optionalChain([options, 'optionalAccess', _42 => _42.asyncFlush]));
4153
5132
  }
4154
5133
  function currentSpan(options) {
4155
- const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _33 => _33.state]), () => ( _globalState));
5134
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _43 => _43.state]), () => ( _globalState));
4156
5135
  return _nullishCoalesce(state.currentSpan.getStore(), () => ( NOOP_SPAN));
4157
5136
  }
4158
5137
  function getSpanParentObject(options) {
4159
- const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _34 => _34.state]), () => ( _globalState));
5138
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _44 => _44.state]), () => ( _globalState));
4160
5139
  const parentSpan = currentSpan({ state });
4161
5140
  if (!Object.is(parentSpan, NOOP_SPAN)) {
4162
5141
  return parentSpan;
4163
5142
  }
5143
+ const parentStr = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _45 => _45.parent]), () => ( state.currentParent.getStore()));
5144
+ if (parentStr) return SpanComponentsV3.fromStr(parentStr);
4164
5145
  const experiment = currentExperiment();
4165
5146
  if (experiment) {
4166
5147
  return experiment;
@@ -4188,7 +5169,7 @@ function traced(callback, args) {
4188
5169
  const { span, isSyncFlushLogger } = startSpanAndIsLogger(args);
4189
5170
  const ret = runCatchFinally(
4190
5171
  () => {
4191
- if (_nullishCoalesce(_optionalChain([args, 'optionalAccess', _35 => _35.setCurrent]), () => ( true))) {
5172
+ if (_nullishCoalesce(_optionalChain([args, 'optionalAccess', _46 => _46.setCurrent]), () => ( true))) {
4192
5173
  return withCurrent(span, callback);
4193
5174
  } else {
4194
5175
  return callback(span);
@@ -4200,7 +5181,7 @@ function traced(callback, args) {
4200
5181
  },
4201
5182
  () => span.end()
4202
5183
  );
4203
- if (_optionalChain([args, 'optionalAccess', _36 => _36.asyncFlush]) === void 0 || _optionalChain([args, 'optionalAccess', _37 => _37.asyncFlush])) {
5184
+ if (_optionalChain([args, 'optionalAccess', _47 => _47.asyncFlush]) === void 0 || _optionalChain([args, 'optionalAccess', _48 => _48.asyncFlush])) {
4204
5185
  return ret;
4205
5186
  } else {
4206
5187
  return (async () => {
@@ -4216,40 +5197,40 @@ function startSpan(args) {
4216
5197
  return startSpanAndIsLogger(args).span;
4217
5198
  }
4218
5199
  async function flush(options) {
4219
- const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _38 => _38.state]), () => ( _globalState));
5200
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _49 => _49.state]), () => ( _globalState));
4220
5201
  return await state.bgLogger().flush();
4221
5202
  }
4222
5203
  function startSpanAndIsLogger(args) {
4223
- const state = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _39 => _39.state]), () => ( _globalState));
4224
- const parentStr = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _40 => _40.parent]), () => ( state.currentParent.getStore()));
4225
- const components = parentStr ? _core.SpanComponentsV3.fromStr(parentStr) : void 0;
4226
- if (components) {
4227
- const parentSpanIds = components.data.row_id ? {
4228
- spanId: components.data.span_id,
4229
- rootSpanId: components.data.root_span_id
5204
+ const state = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _50 => _50.state]), () => ( _globalState));
5205
+ const parentObject = getSpanParentObject({
5206
+ asyncFlush: _optionalChain([args, 'optionalAccess', _51 => _51.asyncFlush]),
5207
+ parent: _optionalChain([args, 'optionalAccess', _52 => _52.parent]),
5208
+ state
5209
+ });
5210
+ if (parentObject instanceof SpanComponentsV3) {
5211
+ const parentSpanIds = parentObject.data.row_id ? {
5212
+ spanId: parentObject.data.span_id,
5213
+ rootSpanId: parentObject.data.root_span_id
4230
5214
  } : void 0;
4231
5215
  const span = new SpanImpl({
4232
5216
  state,
4233
5217
  ...args,
4234
- parentObjectType: components.data.object_type,
5218
+ parentObjectType: parentObject.data.object_type,
4235
5219
  parentObjectId: new LazyValue(
4236
- spanComponentsToObjectIdLambda(state, components)
5220
+ spanComponentsToObjectIdLambda(state, parentObject)
4237
5221
  ),
4238
- parentComputeObjectMetadataArgs: _nullishCoalesce(components.data.compute_object_metadata_args, () => ( void 0)),
5222
+ parentComputeObjectMetadataArgs: _nullishCoalesce(parentObject.data.compute_object_metadata_args, () => ( void 0)),
4239
5223
  parentSpanIds,
4240
- propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _41 => _41.propagatedEvent]), () => ( // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
4241
- (_nullishCoalesce(components.data.propagated_event, () => ( void 0)))))
5224
+ propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _53 => _53.propagatedEvent]), () => ( // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
5225
+ (_nullishCoalesce(parentObject.data.propagated_event, () => ( void 0)))))
4242
5226
  });
4243
5227
  return {
4244
5228
  span,
4245
- isSyncFlushLogger: components.data.object_type === _core.SpanObjectTypeV3.PROJECT_LOGS && // Since there's no parent logger here, we're free to choose the async flush
5229
+ isSyncFlushLogger: parentObject.data.object_type === 2 /* PROJECT_LOGS */ && // Since there's no parent logger here, we're free to choose the async flush
4246
5230
  // behavior, and therefore propagate along whatever we get from the arguments
4247
- _optionalChain([args, 'optionalAccess', _42 => _42.asyncFlush]) === false
5231
+ _optionalChain([args, 'optionalAccess', _54 => _54.asyncFlush]) === false
4248
5232
  };
4249
5233
  } else {
4250
- const parentObject = getSpanParentObject({
4251
- asyncFlush: _optionalChain([args, 'optionalAccess', _43 => _43.asyncFlush])
4252
- });
4253
5234
  const span = parentObject.startSpan(args);
4254
5235
  return {
4255
5236
  span,
@@ -4390,10 +5371,10 @@ function extractAttachments(event, attachments) {
4390
5371
  event[key] = value.reference;
4391
5372
  continue;
4392
5373
  }
4393
- if (_optionalChain([value, 'optionalAccess', _44 => _44.type]) === BRAINTRUST_ATTACHMENT && value.key && !value.uploader) {
5374
+ if (_optionalChain([value, 'optionalAccess', _55 => _55.type]) === BRAINTRUST_ATTACHMENT && value.key && !value.uploader) {
4394
5375
  continue;
4395
5376
  }
4396
- if (_optionalChain([value, 'optionalAccess', _45 => _45.reference, 'optionalAccess', _46 => _46.type]) === BRAINTRUST_ATTACHMENT && _optionalChain([value, 'optionalAccess', _47 => _47.uploader])) {
5377
+ if (_optionalChain([value, 'optionalAccess', _56 => _56.reference, 'optionalAccess', _57 => _57.type]) === BRAINTRUST_ATTACHMENT && _optionalChain([value, 'optionalAccess', _58 => _58.uploader])) {
4397
5378
  const attachment = new Attachment({
4398
5379
  data: value.dataDebugString,
4399
5380
  filename: value.reference.filename,
@@ -4531,7 +5512,7 @@ var ObjectFetcher = (_class8 = class {
4531
5512
  throw new Error("Too many BTQL iterations");
4532
5513
  }
4533
5514
  }
4534
- this._fetchedData = this.mutateRecord ? _optionalChain([data, 'optionalAccess', _48 => _48.map, 'call', _49 => _49(this.mutateRecord)]) : data;
5515
+ this._fetchedData = this.mutateRecord ? _optionalChain([data, 'optionalAccess', _59 => _59.map, 'call', _60 => _60(this.mutateRecord)]) : data;
4535
5516
  }
4536
5517
  return this._fetchedData || [];
4537
5518
  }
@@ -4545,7 +5526,7 @@ var ObjectFetcher = (_class8 = class {
4545
5526
  const fetchedData = await this.fetchedData();
4546
5527
  let maxVersion = void 0;
4547
5528
  for (const record of fetchedData) {
4548
- const xactId = String(_nullishCoalesce(record[_core.TRANSACTION_ID_FIELD], () => ( "0")));
5529
+ const xactId = String(_nullishCoalesce(record[TRANSACTION_ID_FIELD], () => ( "0")));
4549
5530
  if (maxVersion === void 0 || xactId > maxVersion) {
4550
5531
  maxVersion = xactId;
4551
5532
  }
@@ -4588,7 +5569,7 @@ var Experiment2 = (_class9 = class extends ObjectFetcher {
4588
5569
  })();
4589
5570
  }
4590
5571
  parentObjectType() {
4591
- return _core.SpanObjectTypeV3.EXPERIMENT;
5572
+ return 1 /* EXPERIMENT */;
4592
5573
  }
4593
5574
  async getState() {
4594
5575
  await this.lazyMetadata.get();
@@ -4612,7 +5593,7 @@ var Experiment2 = (_class9 = class extends ObjectFetcher {
4612
5593
  * @returns The `id` of the logged event.
4613
5594
  */
4614
5595
  log(event, options) {
4615
- if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _50 => _50.allowConcurrentWithSpans])) {
5596
+ if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _61 => _61.allowConcurrentWithSpans])) {
4616
5597
  throw new Error(
4617
5598
  "Cannot run toplevel `log` method while using spans. To log to the span, call `experiment.traced` and then log with `span.log`"
4618
5599
  );
@@ -4665,14 +5646,14 @@ var Experiment2 = (_class9 = class extends ObjectFetcher {
4665
5646
  state: this.state,
4666
5647
  ...startSpanParentArgs({
4667
5648
  state: this.state,
4668
- parent: _optionalChain([args, 'optionalAccess', _51 => _51.parent]),
5649
+ parent: _optionalChain([args, 'optionalAccess', _62 => _62.parent]),
4669
5650
  parentObjectType: this.parentObjectType(),
4670
5651
  parentObjectId: this.lazyId,
4671
5652
  parentComputeObjectMetadataArgs: void 0,
4672
5653
  parentSpanIds: void 0,
4673
- propagatedEvent: _optionalChain([args, 'optionalAccess', _52 => _52.propagatedEvent])
5654
+ propagatedEvent: _optionalChain([args, 'optionalAccess', _63 => _63.propagatedEvent])
4674
5655
  }),
4675
- defaultRootType: _core.SpanTypeAttribute.EVAL
5656
+ defaultRootType: "eval" /* EVAL */
4676
5657
  });
4677
5658
  }
4678
5659
  async fetchBaseExperiment() {
@@ -4796,7 +5777,7 @@ View complete results in Braintrust or run experiment.summarize() again.`
4796
5777
  * See {@link Span.startSpan} for more details.
4797
5778
  */
4798
5779
  async export() {
4799
- return new (0, _core.SpanComponentsV3)({
5780
+ return new SpanComponentsV3({
4800
5781
  object_type: this.parentObjectType(),
4801
5782
  object_id: await this.id
4802
5783
  }).toStr();
@@ -4883,7 +5864,7 @@ var SpanImpl = (_class10 = class _SpanImpl {
4883
5864
  this.parentComputeObjectMetadataArgs = args.parentComputeObjectMetadataArgs;
4884
5865
  this.propagatedEvent = args.propagatedEvent;
4885
5866
  if (this.propagatedEvent) {
4886
- _core.mergeDicts.call(void 0, rawEvent, this.propagatedEvent);
5867
+ mergeDicts(rawEvent, this.propagatedEvent);
4887
5868
  }
4888
5869
  const { id: eventId, ...event } = rawEvent;
4889
5870
  const callerLocation = isomorph_default.getCallerLocation();
@@ -4960,12 +5941,12 @@ var SpanImpl = (_class10 = class _SpanImpl {
4960
5941
  root_span_id: this._rootSpanId,
4961
5942
  span_parents: this._spanParents,
4962
5943
  ...serializableInternalData,
4963
- [_core.IS_MERGE_FIELD]: this.isMerge
5944
+ [IS_MERGE_FIELD]: this.isMerge
4964
5945
  });
4965
- if (_optionalChain([partialRecord, 'access', _53 => _53.metrics, 'optionalAccess', _54 => _54.end])) {
4966
- this.loggedEndTime = _optionalChain([partialRecord, 'access', _55 => _55.metrics, 'optionalAccess', _56 => _56.end]);
5946
+ if (_optionalChain([partialRecord, 'access', _64 => _64.metrics, 'optionalAccess', _65 => _65.end])) {
5947
+ this.loggedEndTime = _optionalChain([partialRecord, 'access', _66 => _66.metrics, 'optionalAccess', _67 => _67.end]);
4967
5948
  }
4968
- if ((_nullishCoalesce(partialRecord.tags, () => ( []))).length > 0 && _optionalChain([this, 'access', _57 => _57._spanParents, 'optionalAccess', _58 => _58.length])) {
5949
+ if ((_nullishCoalesce(partialRecord.tags, () => ( []))).length > 0 && _optionalChain([this, 'access', _68 => _68._spanParents, 'optionalAccess', _69 => _69.length])) {
4969
5950
  throw new Error("Tags can only be logged to the root span");
4970
5951
  }
4971
5952
  const computeRecord = async () => ({
@@ -4978,7 +5959,7 @@ var SpanImpl = (_class10 = class _SpanImpl {
4978
5959
  ])
4979
5960
  )
4980
5961
  ),
4981
- ...new (0, _core.SpanComponentsV3)({
5962
+ ...new SpanComponentsV3({
4982
5963
  object_type: this.parentObjectType,
4983
5964
  object_id: await this.parentObjectId.get()
4984
5965
  }).objectIdFields()
@@ -5010,18 +5991,18 @@ var SpanImpl = (_class10 = class _SpanImpl {
5010
5991
  );
5011
5992
  }
5012
5993
  startSpan(args) {
5013
- const parentSpanIds = _optionalChain([args, 'optionalAccess', _59 => _59.parent]) ? void 0 : { spanId: this._spanId, rootSpanId: this._rootSpanId };
5994
+ const parentSpanIds = _optionalChain([args, 'optionalAccess', _70 => _70.parent]) ? void 0 : { spanId: this._spanId, rootSpanId: this._rootSpanId };
5014
5995
  return new _SpanImpl({
5015
5996
  state: this._state,
5016
5997
  ...args,
5017
5998
  ...startSpanParentArgs({
5018
5999
  state: this._state,
5019
- parent: _optionalChain([args, 'optionalAccess', _60 => _60.parent]),
6000
+ parent: _optionalChain([args, 'optionalAccess', _71 => _71.parent]),
5020
6001
  parentObjectType: this.parentObjectType,
5021
6002
  parentObjectId: this.parentObjectId,
5022
6003
  parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
5023
6004
  parentSpanIds,
5024
- propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _61 => _61.propagatedEvent]), () => ( this.propagatedEvent))
6005
+ propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _72 => _72.propagatedEvent]), () => ( this.propagatedEvent))
5025
6006
  })
5026
6007
  });
5027
6008
  }
@@ -5035,12 +6016,12 @@ var SpanImpl = (_class10 = class _SpanImpl {
5035
6016
  ...args,
5036
6017
  ...startSpanParentArgs({
5037
6018
  state: this._state,
5038
- parent: _optionalChain([args, 'optionalAccess', _62 => _62.parent]),
6019
+ parent: _optionalChain([args, 'optionalAccess', _73 => _73.parent]),
5039
6020
  parentObjectType: this.parentObjectType,
5040
6021
  parentObjectId: this.parentObjectId,
5041
6022
  parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
5042
6023
  parentSpanIds,
5043
- propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _63 => _63.propagatedEvent]), () => ( this.propagatedEvent))
6024
+ propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _74 => _74.propagatedEvent]), () => ( this.propagatedEvent))
5044
6025
  }),
5045
6026
  spanId
5046
6027
  });
@@ -5049,7 +6030,7 @@ var SpanImpl = (_class10 = class _SpanImpl {
5049
6030
  let endTime;
5050
6031
  let internalData = {};
5051
6032
  if (!this.loggedEndTime) {
5052
- endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _64 => _64.endTime]), () => ( getCurrentUnixTimestamp()));
6033
+ endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _75 => _75.endTime]), () => ( getCurrentUnixTimestamp()));
5053
6034
  internalData = { metrics: { end: endTime } };
5054
6035
  } else {
5055
6036
  endTime = this.loggedEndTime;
@@ -5058,7 +6039,7 @@ var SpanImpl = (_class10 = class _SpanImpl {
5058
6039
  return endTime;
5059
6040
  }
5060
6041
  async export() {
5061
- return new (0, _core.SpanComponentsV3)({
6042
+ return new SpanComponentsV3({
5062
6043
  object_type: this.parentObjectType,
5063
6044
  ...this.parentComputeObjectMetadataArgs && !this.parentObjectId.hasSucceeded ? { compute_object_metadata_args: this.parentComputeObjectMetadataArgs } : { object_id: await this.parentObjectId.get() },
5064
6045
  row_id: this.id,
@@ -5091,9 +6072,9 @@ var SpanImpl = (_class10 = class _SpanImpl {
5091
6072
  const baseUrl = `${appUrl}/app/${orgName}`;
5092
6073
  const args = this.parentComputeObjectMetadataArgs;
5093
6074
  switch (this.parentObjectType) {
5094
- case _core.SpanObjectTypeV3.PROJECT_LOGS: {
5095
- const projectID = _optionalChain([args, 'optionalAccess', _65 => _65.project_id]) || this.parentObjectId.getSync().value;
5096
- const projectName = _optionalChain([args, 'optionalAccess', _66 => _66.project_name]);
6075
+ case 2 /* PROJECT_LOGS */: {
6076
+ const projectID = _optionalChain([args, 'optionalAccess', _76 => _76.project_id]) || this.parentObjectId.getSync().value;
6077
+ const projectName = _optionalChain([args, 'optionalAccess', _77 => _77.project_name]);
5097
6078
  if (projectID) {
5098
6079
  return `${baseUrl}/object?object_type=project_logs&object_id=${projectID}&id=${this._id}`;
5099
6080
  } else if (projectName) {
@@ -5102,15 +6083,15 @@ var SpanImpl = (_class10 = class _SpanImpl {
5102
6083
  return getErrPermlink("provide-project-name-or-id");
5103
6084
  }
5104
6085
  }
5105
- case _core.SpanObjectTypeV3.EXPERIMENT: {
5106
- const expID = _optionalChain([args, 'optionalAccess', _67 => _67.experiment_id]) || _optionalChain([this, 'access', _68 => _68.parentObjectId, 'optionalAccess', _69 => _69.getSync, 'call', _70 => _70(), 'optionalAccess', _71 => _71.value]);
6086
+ case 1 /* EXPERIMENT */: {
6087
+ const expID = _optionalChain([args, 'optionalAccess', _78 => _78.experiment_id]) || _optionalChain([this, 'access', _79 => _79.parentObjectId, 'optionalAccess', _80 => _80.getSync, 'call', _81 => _81(), 'optionalAccess', _82 => _82.value]);
5107
6088
  if (!expID) {
5108
6089
  return getErrPermlink("provide-experiment-id");
5109
6090
  } else {
5110
6091
  return `${baseUrl}/object?object_type=experiment&object_id=${expID}&id=${this._id}`;
5111
6092
  }
5112
6093
  }
5113
- case _core.SpanObjectTypeV3.PLAYGROUND_LOGS: {
6094
+ case 3 /* PLAYGROUND_LOGS */: {
5114
6095
  return NOOP_SPAN_PERMALINK;
5115
6096
  }
5116
6097
  default: {
@@ -5136,8 +6117,8 @@ function splitLoggingData({
5136
6117
  }) {
5137
6118
  const sanitized = validateAndSanitizeExperimentLogPartialArgs(_nullishCoalesce(event, () => ( {})));
5138
6119
  const sanitizedAndInternalData = {};
5139
- _core.mergeDicts.call(void 0, sanitizedAndInternalData, internalData || {});
5140
- _core.mergeDicts.call(void 0, sanitizedAndInternalData, sanitized);
6120
+ mergeDicts(sanitizedAndInternalData, internalData || {});
6121
+ mergeDicts(sanitizedAndInternalData, sanitized);
5141
6122
  const serializableInternalData = {};
5142
6123
  const lazyInternalData = {};
5143
6124
  for (const [key, value] of Object.entries(sanitizedAndInternalData)) {
@@ -5162,7 +6143,7 @@ function splitLoggingData({
5162
6143
  }
5163
6144
  var Dataset2 = (_class11 = class extends ObjectFetcher {
5164
6145
  constructor(state, lazyMetadata, pinnedVersion, legacy, _internal_btql) {
5165
- const isLegacyDataset = _nullishCoalesce(legacy, () => ( _core.DEFAULT_IS_LEGACY_DATASET));
6146
+ const isLegacyDataset = _nullishCoalesce(legacy, () => ( DEFAULT_IS_LEGACY_DATASET));
5166
6147
  if (isLegacyDataset) {
5167
6148
  console.warn(
5168
6149
  `Records will be fetched from this dataset in the legacy format, with the "expected" field renamed to "output". Please update your code to use "expected", and use \`braintrust.initDataset()\` with \`{ useOutput: false }\`, which will become the default in a future version of Braintrust.`
@@ -5173,7 +6154,7 @@ var Dataset2 = (_class11 = class extends ObjectFetcher {
5173
6154
  pinnedVersion,
5174
6155
  (r) => (
5175
6156
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
5176
- _core.ensureDatasetRecord.call(void 0,
6157
+ ensureDatasetRecord(
5177
6158
  enrichAttachments(r, this.state),
5178
6159
  isLegacyDataset
5179
6160
  )
@@ -5249,7 +6230,7 @@ var Dataset2 = (_class11 = class extends ObjectFetcher {
5249
6230
  //if we're merging/updating an event we will not add this ts
5250
6231
  metadata,
5251
6232
  ...!!isMerge ? {
5252
- [_core.IS_MERGE_FIELD]: true
6233
+ [IS_MERGE_FIELD]: true
5253
6234
  } : {}
5254
6235
  };
5255
6236
  return args;
@@ -5410,7 +6391,7 @@ function renderMessage(render, message) {
5410
6391
  case "text":
5411
6392
  return { ...c, text: render(c.text) };
5412
6393
  case "image_url":
5413
- if (_core.isObject.call(void 0, c.image_url.url)) {
6394
+ if (isObject(c.image_url.url)) {
5414
6395
  throw new Error(
5415
6396
  "Attachments must be replaced with URLs before calling `build()`"
5416
6397
  );
@@ -5469,9 +6450,9 @@ function renderTemplatedObject(obj, args, options) {
5469
6450
  }
5470
6451
  }
5471
6452
  });
5472
- } else if (_core.isArray.call(void 0, obj)) {
6453
+ } else if (isArray(obj)) {
5473
6454
  return obj.map((item) => renderTemplatedObject(item, args, options));
5474
- } else if (_core.isObject.call(void 0, obj)) {
6455
+ } else if (isObject(obj)) {
5475
6456
  return Object.fromEntries(
5476
6457
  Object.entries(obj).map(([key, value]) => [
5477
6458
  key,
@@ -5529,13 +6510,13 @@ var Prompt2 = (_class12 = class _Prompt {
5529
6510
  return "slug" in this.metadata ? this.metadata.slug : this.metadata.id;
5530
6511
  }
5531
6512
  get prompt() {
5532
- return _optionalChain([this, 'access', _72 => _72.getParsedPromptData, 'call', _73 => _73(), 'optionalAccess', _74 => _74.prompt]);
6513
+ return _optionalChain([this, 'access', _83 => _83.getParsedPromptData, 'call', _84 => _84(), 'optionalAccess', _85 => _85.prompt]);
5533
6514
  }
5534
6515
  get version() {
5535
- return this.metadata[_core.TRANSACTION_ID_FIELD];
6516
+ return this.metadata[TRANSACTION_ID_FIELD];
5536
6517
  }
5537
6518
  get options() {
5538
- return _optionalChain([this, 'access', _75 => _75.getParsedPromptData, 'call', _76 => _76(), 'optionalAccess', _77 => _77.options]) || {};
6519
+ return _optionalChain([this, 'access', _86 => _86.getParsedPromptData, 'call', _87 => _87(), 'optionalAccess', _88 => _88.options]) || {};
5539
6520
  }
5540
6521
  get promptData() {
5541
6522
  return this.getParsedPromptData();
@@ -5686,7 +6667,7 @@ var Prompt2 = (_class12 = class _Prompt {
5686
6667
  return {
5687
6668
  type: "chat",
5688
6669
  messages,
5689
- ..._optionalChain([prompt, 'access', _78 => _78.tools, 'optionalAccess', _79 => _79.trim, 'call', _80 => _80()]) ? {
6670
+ ..._optionalChain([prompt, 'access', _89 => _89.tools, 'optionalAccess', _90 => _90.trim, 'call', _91 => _91()]) ? {
5690
6671
  tools: render(prompt.tools)
5691
6672
  } : void 0
5692
6673
  };
@@ -5767,9 +6748,6 @@ function configureNode() {
5767
6748
  var _express = require('express'); var _express2 = _interopRequireDefault(_express);
5768
6749
  var _cors = require('cors'); var _cors2 = _interopRequireDefault(_cors);
5769
6750
 
5770
- // src/framework.ts
5771
-
5772
-
5773
6751
  // ../../node_modules/.pnpm/async@3.2.5/node_modules/async/dist/async.mjs
5774
6752
  function initialParams(fn) {
5775
6753
  return function(...args) {
@@ -6855,7 +7833,6 @@ var BarProgressReporter = (_class13 = class {
6855
7833
 
6856
7834
  var _slugify = require('slugify'); var _slugify2 = _interopRequireDefault(_slugify);
6857
7835
 
6858
-
6859
7836
  var ProjectBuilder = class {
6860
7837
  create(opts) {
6861
7838
  return new Project2(opts);
@@ -7089,23 +8066,23 @@ var CodePrompt = class {
7089
8066
  };
7090
8067
  }
7091
8068
  };
7092
- var promptContentsSchema = _zod.z.union([
7093
- _zod.z.object({
7094
- prompt: _zod.z.string()
8069
+ var promptContentsSchema = _v3.z.union([
8070
+ _v3.z.object({
8071
+ prompt: _v3.z.string()
7095
8072
  }),
7096
- _zod.z.object({
7097
- messages: _zod.z.array(ChatCompletionMessageParam)
8073
+ _v3.z.object({
8074
+ messages: _v3.z.array(ChatCompletionMessageParam)
7098
8075
  })
7099
8076
  ]);
7100
8077
  var promptDefinitionSchema = promptContentsSchema.and(
7101
- _zod.z.object({
7102
- model: _zod.z.string(),
8078
+ _v3.z.object({
8079
+ model: _v3.z.string(),
7103
8080
  params: ModelParams.optional()
7104
8081
  })
7105
8082
  );
7106
8083
  var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
7107
- _zod.z.object({
7108
- tools: _zod.z.array(ToolFunctionDefinition).optional()
8084
+ _v3.z.object({
8085
+ tools: _v3.z.array(ToolFunctionDefinition).optional()
7109
8086
  })
7110
8087
  );
7111
8088
  var PromptBuilder = class {
@@ -7128,7 +8105,7 @@ var PromptBuilder = class {
7128
8105
  const promptData = promptDefinitionToPromptData(opts, rawTools);
7129
8106
  const promptRow = {
7130
8107
  id: opts.id,
7131
- _xact_id: opts.version ? _core.loadPrettyXact.call(void 0, opts.version) : void 0,
8108
+ _xact_id: opts.version ? loadPrettyXact(opts.version) : void 0,
7132
8109
  name: opts.name,
7133
8110
  slug,
7134
8111
  prompt_data: promptData,
@@ -7173,7 +8150,7 @@ var ProjectNameIdMap = (_class17 = class {constructor() { _class17.prototype.__i
7173
8150
  const response = await _internalGetGlobalState().appConn().post_json("api/project/register", {
7174
8151
  project_name: projectName
7175
8152
  });
7176
- const result = _zod.z.object({
8153
+ const result = _v3.z.object({
7177
8154
  project: Project
7178
8155
  }).parse(response);
7179
8156
  const projectId = result.project.id;
@@ -7187,7 +8164,7 @@ var ProjectNameIdMap = (_class17 = class {constructor() { _class17.prototype.__i
7187
8164
  const response = await _internalGetGlobalState().appConn().post_json("api/project/get", {
7188
8165
  id: projectId
7189
8166
  });
7190
- const result = _zod.z.array(Project).nonempty().parse(response);
8167
+ const result = _v3.z.array(Project).nonempty().parse(response);
7191
8168
  const projectName = result[0].name;
7192
8169
  this.idToName[projectId] = projectName;
7193
8170
  this.nameToId[projectName] = projectId;
@@ -7203,15 +8180,15 @@ var ProjectNameIdMap = (_class17 = class {constructor() { _class17.prototype.__i
7203
8180
  }, _class17);
7204
8181
 
7205
8182
  // src/eval-parameters.ts
7206
- var evalParametersSchema = _zod.z.record(
7207
- _zod.z.string(),
7208
- _zod.z.union([
7209
- _zod.z.object({
7210
- type: _zod.z.literal("prompt"),
8183
+ var evalParametersSchema = _v3.z.record(
8184
+ _v3.z.string(),
8185
+ _v3.z.union([
8186
+ _v3.z.object({
8187
+ type: _v3.z.literal("prompt"),
7211
8188
  default: promptDefinitionWithToolsSchema.optional(),
7212
- description: _zod.z.string().optional()
8189
+ description: _v3.z.string().optional()
7213
8190
  }),
7214
- _zod.z.instanceof(_zod.z.ZodType)
8191
+ _v3.z.instanceof(_v3.z.ZodType)
7215
8192
  // For Zod schemas
7216
8193
  ])
7217
8194
  );
@@ -7491,7 +8468,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
7491
8468
  const baseEvent = {
7492
8469
  name: "eval",
7493
8470
  spanAttributes: {
7494
- type: _core.SpanTypeAttribute.EVAL
8471
+ type: "eval" /* EVAL */
7495
8472
  },
7496
8473
  event: {
7497
8474
  input: datum.input,
@@ -7529,10 +8506,10 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
7529
8506
  span,
7530
8507
  parameters: _nullishCoalesce(parameters, () => ( {})),
7531
8508
  reportProgress: (event) => {
7532
- _optionalChain([stream, 'optionalCall', _81 => _81({
8509
+ _optionalChain([stream, 'optionalCall', _92 => _92({
7533
8510
  ...event,
7534
8511
  id: rootSpan.id,
7535
- origin: _optionalChain([baseEvent, 'access', _82 => _82.event, 'optionalAccess', _83 => _83.origin]),
8512
+ origin: _optionalChain([baseEvent, 'access', _93 => _93.event, 'optionalAccess', _94 => _94.origin]),
7536
8513
  name: evaluator.evalName,
7537
8514
  object_type: "task"
7538
8515
  })]);
@@ -7551,7 +8528,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
7551
8528
  },
7552
8529
  {
7553
8530
  name: "task",
7554
- spanAttributes: { type: _core.SpanTypeAttribute.TASK },
8531
+ spanAttributes: { type: "task" /* TASK */ },
7555
8532
  event: { input: datum.input }
7556
8533
  }
7557
8534
  );
@@ -7597,17 +8574,17 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
7597
8574
  return rest;
7598
8575
  };
7599
8576
  const resultMetadata = results3.length === 1 ? results3[0].metadata : results3.reduce(
7600
- (prev, s) => _core.mergeDicts.call(void 0, prev, {
8577
+ (prev, s) => mergeDicts(prev, {
7601
8578
  [s.name]: s.metadata
7602
8579
  }),
7603
8580
  {}
7604
8581
  );
7605
8582
  const resultOutput = results3.length === 1 ? getOtherFields(results3[0]) : results3.reduce(
7606
- (prev, s) => _core.mergeDicts.call(void 0, prev, { [s.name]: getOtherFields(s) }),
8583
+ (prev, s) => mergeDicts(prev, { [s.name]: getOtherFields(s) }),
7607
8584
  {}
7608
8585
  );
7609
8586
  const scores2 = results3.reduce(
7610
- (prev, s) => _core.mergeDicts.call(void 0, prev, { [s.name]: s.score }),
8587
+ (prev, s) => mergeDicts(prev, { [s.name]: s.score }),
7611
8588
  {}
7612
8589
  );
7613
8590
  span.log({
@@ -7620,7 +8597,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
7620
8597
  const results2 = await rootSpan.traced(runScorer, {
7621
8598
  name: scorerNames[score_idx],
7622
8599
  spanAttributes: {
7623
- type: _core.SpanTypeAttribute.SCORE
8600
+ type: "score" /* SCORE */
7624
8601
  },
7625
8602
  event: { input: scoringArgs }
7626
8603
  });
@@ -7682,7 +8659,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
7682
8659
  ...scores
7683
8660
  },
7684
8661
  error: error2,
7685
- origin: _optionalChain([baseEvent, 'access', _84 => _84.event, 'optionalAccess', _85 => _85.origin])
8662
+ origin: _optionalChain([baseEvent, 'access', _95 => _95.event, 'optionalAccess', _96 => _96.origin])
7686
8663
  });
7687
8664
  };
7688
8665
  if (!experiment) {
@@ -7849,7 +8826,7 @@ var errorHandler = (err, req, res, next) => {
7849
8826
  });
7850
8827
  return;
7851
8828
  }
7852
- if (err instanceof _zod.z.ZodError) {
8829
+ if (err instanceof _v3.z.ZodError) {
7853
8830
  res.status(400).json({
7854
8831
  error: {
7855
8832
  message: "Invalid request",
@@ -7873,7 +8850,8 @@ function authorizeRequest(req, res, next) {
7873
8850
  try {
7874
8851
  const ctx = {
7875
8852
  appOrigin: extractAllowedOrigin(req.headers[ORIGIN_HEADER]),
7876
- token: void 0
8853
+ token: void 0,
8854
+ state: void 0
7877
8855
  };
7878
8856
  if (req.headers.authorization || req.headers[BRAINTRUST_AUTH_TOKEN_HEADER]) {
7879
8857
  const tokenText = parseBraintrustAuthHeader(req.headers);
@@ -7888,11 +8866,37 @@ function authorizeRequest(req, res, next) {
7888
8866
  next(e);
7889
8867
  }
7890
8868
  }
7891
- function checkAuthorized(req, res, next) {
7892
- if (!_optionalChain([req, 'access', _86 => _86.ctx, 'optionalAccess', _87 => _87.token])) {
7893
- return next(_httperrors2.default.call(void 0, 401, "Unauthorized"));
8869
+ var loginCache = new LRUCache({
8870
+ max: 32
8871
+ // TODO: Make this configurable
8872
+ });
8873
+ async function cachedLogin(options) {
8874
+ const key = JSON.stringify(options);
8875
+ const cached = loginCache.get(key);
8876
+ if (cached) {
8877
+ return cached;
7894
8878
  }
7895
- next();
8879
+ const state = await loginToState(options);
8880
+ loginCache.set(key, state);
8881
+ return state;
8882
+ }
8883
+ function makeCheckAuthorized(allowedOrgName) {
8884
+ return async (req, _res, next) => {
8885
+ if (!_optionalChain([req, 'access', _97 => _97.ctx, 'optionalAccess', _98 => _98.token])) {
8886
+ return next(_httperrors2.default.call(void 0, 401, "Unauthorized"));
8887
+ }
8888
+ try {
8889
+ const state = await cachedLogin({
8890
+ apiKey: _optionalChain([req, 'access', _99 => _99.ctx, 'optionalAccess', _100 => _100.token]),
8891
+ orgName: allowedOrgName
8892
+ });
8893
+ req.ctx.state = state;
8894
+ next();
8895
+ } catch (e) {
8896
+ console.error("Authorization error:", e);
8897
+ return next(_httperrors2.default.call(void 0, 401, "Unauthorized"));
8898
+ }
8899
+ };
7896
8900
  }
7897
8901
  function parseBraintrustAuthHeader(headers) {
7898
8902
  const tokenString = parseHeader(headers, BRAINTRUST_AUTH_TOKEN_HEADER);
@@ -7977,13 +8981,6 @@ var baseAllowedHeaders = [
7977
8981
  "x-stainless-arch"
7978
8982
  ];
7979
8983
 
7980
- // dev/server.ts
7981
-
7982
-
7983
-
7984
-
7985
-
7986
-
7987
8984
  // dev/stream.ts
7988
8985
  function serializeSSEEvent(event) {
7989
8986
  return Object.entries(event).filter(([_key, value]) => value !== void 0).map(([key, value]) => `${key}: ${value}`).join("\n") + "\n\n";
@@ -7991,43 +8988,43 @@ function serializeSSEEvent(event) {
7991
8988
 
7992
8989
  // dev/types.ts
7993
8990
 
7994
- var evalBodySchema = _zod.z.object({
7995
- name: _zod.z.string(),
7996
- parameters: _zod.z.record(_zod.z.string(), _zod.z.unknown()).nullish(),
8991
+ var evalBodySchema = _v3.z.object({
8992
+ name: _v3.z.string(),
8993
+ parameters: _v3.z.record(_v3.z.string(), _v3.z.unknown()).nullish(),
7997
8994
  data: RunEval.shape.data,
7998
- scores: _zod.z.array(
7999
- _zod.z.object({
8995
+ scores: _v3.z.array(
8996
+ _v3.z.object({
8000
8997
  function_id: FunctionId,
8001
- name: _zod.z.string()
8998
+ name: _v3.z.string()
8002
8999
  })
8003
9000
  ).nullish(),
8004
- experiment_name: _zod.z.string().nullish(),
8005
- project_id: _zod.z.string().nullish(),
9001
+ experiment_name: _v3.z.string().nullish(),
9002
+ project_id: _v3.z.string().nullish(),
8006
9003
  parent: InvokeParent.optional(),
8007
- stream: _zod.z.boolean().optional()
9004
+ stream: _v3.z.boolean().optional()
8008
9005
  });
8009
- var evalParametersSerializedSchema = _zod.z.record(
8010
- _zod.z.string(),
8011
- _zod.z.union([
8012
- _zod.z.object({
8013
- type: _zod.z.literal("prompt"),
9006
+ var evalParametersSerializedSchema = _v3.z.record(
9007
+ _v3.z.string(),
9008
+ _v3.z.union([
9009
+ _v3.z.object({
9010
+ type: _v3.z.literal("prompt"),
8014
9011
  default: PromptData.optional(),
8015
- description: _zod.z.string().optional()
9012
+ description: _v3.z.string().optional()
8016
9013
  }),
8017
- _zod.z.object({
8018
- type: _zod.z.literal("data"),
8019
- schema: _zod.z.record(_zod.z.unknown()),
9014
+ _v3.z.object({
9015
+ type: _v3.z.literal("data"),
9016
+ schema: _v3.z.record(_v3.z.unknown()),
8020
9017
  // JSON Schema
8021
- default: _zod.z.unknown().optional(),
8022
- description: _zod.z.string().optional()
9018
+ default: _v3.z.unknown().optional(),
9019
+ description: _v3.z.string().optional()
8023
9020
  })
8024
9021
  ])
8025
9022
  );
8026
- var evaluatorDefinitionSchema = _zod.z.object({
9023
+ var evaluatorDefinitionSchema = _v3.z.object({
8027
9024
  parameters: evalParametersSerializedSchema.optional()
8028
9025
  });
8029
- var evaluatorDefinitionsSchema = _zod.z.record(
8030
- _zod.z.string(),
9026
+ var evaluatorDefinitionsSchema = _v3.z.record(
9027
+ _v3.z.string(),
8031
9028
  evaluatorDefinitionSchema
8032
9029
  );
8033
9030
 
@@ -8048,6 +9045,7 @@ function runDevServer(evaluators, opts) {
8048
9045
  }
8049
9046
  next();
8050
9047
  });
9048
+ const checkAuthorized = makeCheckAuthorized(opts.orgName);
8051
9049
  app.use(
8052
9050
  _cors2.default.call(void 0, {
8053
9051
  origin: checkOrigin,
@@ -8055,8 +9053,8 @@ function runDevServer(evaluators, opts) {
8055
9053
  allowedHeaders: baseAllowedHeaders,
8056
9054
  credentials: true,
8057
9055
  exposedHeaders: [
8058
- _core.BT_CURSOR_HEADER,
8059
- _core.BT_FOUND_EXISTING_HEADER,
9056
+ BT_CURSOR_HEADER,
9057
+ BT_FOUND_EXISTING_HEADER,
8060
9058
  "x-bt-span-id",
8061
9059
  "x-bt-span-export"
8062
9060
  ],
@@ -8067,7 +9065,7 @@ function runDevServer(evaluators, opts) {
8067
9065
  app.get("/", (req, res) => {
8068
9066
  res.send("Hello, world!");
8069
9067
  });
8070
- app.get("/list", (req, res) => {
9068
+ app.get("/list", checkAuthorized, (req, res) => {
8071
9069
  const evalDefs = Object.fromEntries(
8072
9070
  Object.entries(allEvaluators).map(([name, evaluator]) => [
8073
9071
  name,
@@ -8095,7 +9093,11 @@ function runDevServer(evaluators, opts) {
8095
9093
  scores,
8096
9094
  stream
8097
9095
  } = evalBodySchema.parse(req.body);
8098
- const state = await cachedLogin({ apiKey: _optionalChain([req, 'access', _88 => _88.ctx, 'optionalAccess', _89 => _89.token]) });
9096
+ if (!_optionalChain([req, 'access', _101 => _101.ctx, 'optionalAccess', _102 => _102.state])) {
9097
+ res.status(500).json({ error: "Braintrust state not initialized in request" });
9098
+ return;
9099
+ }
9100
+ const state = req.ctx.state;
8099
9101
  const evaluator = allEvaluators[name];
8100
9102
  if (!evaluator) {
8101
9103
  res.status(404).json({ error: `Evaluator '${name}' not found` });
@@ -8112,7 +9114,7 @@ function runDevServer(evaluators, opts) {
8112
9114
  validateParameters(_nullishCoalesce(parameters, () => ( {})), evaluator.parameters);
8113
9115
  } catch (e) {
8114
9116
  console.error("Error validating parameters", e);
8115
- if (e instanceof _zod.z.ZodError || e instanceof Error) {
9117
+ if (e instanceof _v3.z.ZodError || e instanceof Error) {
8116
9118
  res.status(400).json({
8117
9119
  error: e.message
8118
9120
  });
@@ -8148,7 +9150,7 @@ function runDevServer(evaluators, opts) {
8148
9150
  ...evaluator,
8149
9151
  data: evalData.data,
8150
9152
  scores: evaluator.scores.concat(
8151
- _nullishCoalesce(_optionalChain([scores, 'optionalAccess', _90 => _90.map, 'call', _91 => _91(
9153
+ _nullishCoalesce(_optionalChain([scores, 'optionalAccess', _103 => _103.map, 'call', _104 => _104(
8152
9154
  (score) => makeScorer(state, score.name, score.function_id)
8153
9155
  )]), () => ( []))
8154
9156
  ),
@@ -8188,7 +9190,7 @@ function runDevServer(evaluators, opts) {
8188
9190
  );
8189
9191
  }
8190
9192
  },
8191
- parent: _core.parseParent.call(void 0, parent),
9193
+ parent: parseParent(parent),
8192
9194
  parameters: _nullishCoalesce(parameters, () => ( {}))
8193
9195
  }
8194
9196
  );
@@ -8233,20 +9235,6 @@ function runDevServer(evaluators, opts) {
8233
9235
  var asyncHandler = (fn) => (req, res, next) => {
8234
9236
  Promise.resolve(fn(req, res, next)).catch(next);
8235
9237
  };
8236
- var loginCache = new LRUCache({
8237
- max: 32
8238
- // TODO: Make this configurable
8239
- });
8240
- async function cachedLogin(options) {
8241
- const key = JSON.stringify(options);
8242
- const cached = loginCache.get(key);
8243
- if (cached) {
8244
- return cached;
8245
- }
8246
- const state = await loginToState(options);
8247
- loginCache.set(key, state);
8248
- return state;
8249
- }
8250
9238
  async function getDataset(state, data) {
8251
9239
  if ("project_name" in data) {
8252
9240
  return initDataset({
@@ -8270,9 +9258,9 @@ async function getDataset(state, data) {
8270
9258
  return data.data;
8271
9259
  }
8272
9260
  }
8273
- var datasetFetchSchema = _zod.z.object({
8274
- project_id: _zod.z.string(),
8275
- name: _zod.z.string()
9261
+ var datasetFetchSchema = _v3.z.object({
9262
+ project_id: _v3.z.string(),
9263
+ name: _v3.z.string()
8276
9264
  });
8277
9265
  async function getDatasetById({
8278
9266
  state,
@@ -8281,7 +9269,7 @@ async function getDatasetById({
8281
9269
  const dataset = await state.appConn().post_json("api/dataset/get", {
8282
9270
  id: datasetId
8283
9271
  });
8284
- const parsed = _zod.z.array(datasetFetchSchema).parse(dataset);
9272
+ const parsed = _v3.z.array(datasetFetchSchema).parse(dataset);
8285
9273
  if (parsed.length === 0) {
8286
9274
  throw new Error(`Dataset '${datasetId}' not found`);
8287
9275
  }