braintrust 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.mjs CHANGED
@@ -87,33 +87,990 @@ var Queue = class {
87
87
  }
88
88
  };
89
89
 
90
- // src/logger.ts
91
- import {
92
- _urljoin,
93
- AUDIT_METADATA_FIELD,
94
- AUDIT_SOURCE_FIELD,
95
- batchItems,
96
- constructJsonArray,
97
- DEFAULT_IS_LEGACY_DATASET,
98
- ensureDatasetRecord,
99
- IS_MERGE_FIELD,
100
- mergeDicts,
101
- mergeGitMetadataSettings,
102
- mergeRowBatch,
103
- SpanComponentsV3,
104
- SpanObjectTypeV3,
105
- spanObjectTypeV3ToString,
106
- SpanTypeAttribute,
107
- TRANSACTION_ID_FIELD,
108
- VALID_SOURCES,
109
- isArray,
110
- isObject
111
- } from "@braintrust/core";
90
+ // util/db_fields.ts
91
+ var TRANSACTION_ID_FIELD = "_xact_id";
92
+ var IS_MERGE_FIELD = "_is_merge";
93
+ var AUDIT_SOURCE_FIELD = "_audit_source";
94
+ var AUDIT_METADATA_FIELD = "_audit_metadata";
95
+ var VALID_SOURCES = ["app", "api", "external"];
96
+ var PARENT_ID_FIELD = "_parent_id";
97
+
98
+ // util/span_identifier_v3.ts
99
+ import * as uuid3 from "uuid";
100
+
101
+ // util/span_identifier_v2.ts
102
+ import * as uuid2 from "uuid";
103
+
104
+ // util/span_identifier_v1.ts
105
+ import * as uuid from "uuid";
106
+ import { z } from "zod/v3";
107
+ function tryMakeUuid(s) {
108
+ try {
109
+ const ret = uuid.parse(s);
110
+ if (ret.length !== 16) {
111
+ throw new Error();
112
+ }
113
+ return { bytes: Buffer.from(ret), isUUID: true };
114
+ } catch (e) {
115
+ return { bytes: Buffer.from(s, "utf-8"), isUUID: false };
116
+ }
117
+ }
118
+ var ENCODING_VERSION_NUMBER = 1;
119
+ 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";
120
+ var SpanObjectTypeV1 = /* @__PURE__ */ ((SpanObjectTypeV12) => {
121
+ SpanObjectTypeV12[SpanObjectTypeV12["EXPERIMENT"] = 1] = "EXPERIMENT";
122
+ SpanObjectTypeV12[SpanObjectTypeV12["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
123
+ return SpanObjectTypeV12;
124
+ })(SpanObjectTypeV1 || {});
125
+ var SpanObjectTypeV1EnumSchema = z.nativeEnum(SpanObjectTypeV1);
126
+ var SpanRowIdsV1 = class {
127
+ rowId;
128
+ spanId;
129
+ rootSpanId;
130
+ constructor(args) {
131
+ this.rowId = args.rowId;
132
+ this.spanId = args.spanId;
133
+ this.rootSpanId = args.rootSpanId;
134
+ if (!this.rowId) {
135
+ throw new Error("rowId must be nonempty string");
136
+ }
137
+ if (!this.spanId) {
138
+ throw new Error("spanId must be nonempty string");
139
+ }
140
+ if (!this.rootSpanId) {
141
+ throw new Error("rootSpanId must be nonempty string");
142
+ }
143
+ }
144
+ toObject() {
145
+ return {
146
+ rowId: this.rowId,
147
+ spanId: this.spanId,
148
+ rootSpanId: this.rootSpanId
149
+ };
150
+ }
151
+ };
152
+ var SpanComponentsV1 = class _SpanComponentsV1 {
153
+ objectType;
154
+ objectId;
155
+ rowIds;
156
+ constructor(args) {
157
+ this.objectType = args.objectType;
158
+ this.objectId = args.objectId;
159
+ this.rowIds = args.rowIds;
160
+ }
161
+ toStr() {
162
+ const allBuffers = [];
163
+ const { bytes: rowIdBytes, isUUID: rowIdIsUUID } = this.rowIds ? tryMakeUuid(this.rowIds.rowId) : { bytes: Buffer.from(""), isUUID: false };
164
+ allBuffers.push(
165
+ Buffer.from([
166
+ ENCODING_VERSION_NUMBER,
167
+ this.objectType,
168
+ this.rowIds ? 1 : 0,
169
+ rowIdIsUUID ? 1 : 0
170
+ ])
171
+ );
172
+ const { bytes: objectIdBytes, isUUID: objectIdIsUUID } = tryMakeUuid(
173
+ this.objectId
174
+ );
175
+ if (!objectIdIsUUID) {
176
+ throw new Error("object_id component must be a valid UUID");
177
+ }
178
+ allBuffers.push(objectIdBytes);
179
+ if (this.rowIds) {
180
+ const { bytes: spanIdBytes, isUUID: spanIdIsUUID } = tryMakeUuid(
181
+ this.rowIds.spanId
182
+ );
183
+ if (!spanIdIsUUID) {
184
+ throw new Error("span_id component must be a valid UUID");
185
+ }
186
+ const { bytes: rootSpanIdBytes, isUUID: rootSpanIdIsUUID } = tryMakeUuid(
187
+ this.rowIds.rootSpanId
188
+ );
189
+ if (!rootSpanIdIsUUID) {
190
+ throw new Error("root_span_id component must be a valid UUID");
191
+ }
192
+ allBuffers.push(spanIdBytes, rootSpanIdBytes, rowIdBytes);
193
+ }
194
+ return Buffer.concat(allBuffers).toString("base64");
195
+ }
196
+ static fromStr(s) {
197
+ try {
198
+ const rawBytes = Buffer.from(s, "base64");
199
+ if (rawBytes[0] !== ENCODING_VERSION_NUMBER) {
200
+ throw new Error();
201
+ }
202
+ const objectType = SpanObjectTypeV1EnumSchema.parse(rawBytes[1]);
203
+ if (![0, 1].includes(rawBytes[2])) {
204
+ throw new Error();
205
+ }
206
+ if (![0, 1].includes(rawBytes[3])) {
207
+ throw new Error();
208
+ }
209
+ const hasRowId = rawBytes[2] == 1;
210
+ const rowIdIsUUID = rawBytes[3] == 1;
211
+ const objectId = uuid.stringify(rawBytes.subarray(4, 20));
212
+ const rowIds = (() => {
213
+ if (!hasRowId) {
214
+ return void 0;
215
+ }
216
+ const spanId = uuid.stringify(rawBytes.subarray(20, 36));
217
+ const rootSpanId = uuid.stringify(rawBytes.subarray(36, 52));
218
+ const rowId = rowIdIsUUID ? uuid.stringify(rawBytes.subarray(52)) : rawBytes.subarray(52).toString("utf-8");
219
+ return new SpanRowIdsV1({ rowId, spanId, rootSpanId });
220
+ })();
221
+ return new _SpanComponentsV1({ objectType, objectId, rowIds });
222
+ } catch (e) {
223
+ throw new Error(INVALID_ENCODING_ERRMSG);
224
+ }
225
+ }
226
+ objectIdFields() {
227
+ switch (this.objectType) {
228
+ case 1 /* EXPERIMENT */:
229
+ return { experiment_id: this.objectId };
230
+ case 2 /* PROJECT_LOGS */:
231
+ return { project_id: this.objectId, log_id: "g" };
232
+ default:
233
+ throw new Error("Impossible");
234
+ }
235
+ }
236
+ toObject() {
237
+ return {
238
+ objectType: this.objectType,
239
+ objectId: this.objectId,
240
+ rowIds: this.rowIds?.toObject()
241
+ };
242
+ }
243
+ };
244
+
245
+ // util/span_identifier_v2.ts
246
+ import { z as z2 } from "zod/v3";
247
+ function tryMakeUuid2(s) {
248
+ try {
249
+ const ret = uuid2.parse(s);
250
+ if (ret.length !== 16) {
251
+ throw new Error();
252
+ }
253
+ return { bytes: Buffer.from(ret), isUUID: true };
254
+ } catch (e) {
255
+ return { bytes: Buffer.from(s, "utf-8"), isUUID: false };
256
+ }
257
+ }
258
+ var ENCODING_VERSION_NUMBER2 = 2;
259
+ 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.`;
260
+ var INTEGER_ENCODING_NUM_BYTES = 4;
261
+ var SpanObjectTypeV2 = /* @__PURE__ */ ((SpanObjectTypeV22) => {
262
+ SpanObjectTypeV22[SpanObjectTypeV22["EXPERIMENT"] = 1] = "EXPERIMENT";
263
+ SpanObjectTypeV22[SpanObjectTypeV22["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
264
+ return SpanObjectTypeV22;
265
+ })(SpanObjectTypeV2 || {});
266
+ var SpanObjectTypeV2EnumSchema = z2.nativeEnum(SpanObjectTypeV2);
267
+ var SpanRowIdsV2 = class {
268
+ rowId;
269
+ spanId;
270
+ rootSpanId;
271
+ constructor(args) {
272
+ this.rowId = args.rowId;
273
+ this.spanId = args.spanId;
274
+ this.rootSpanId = args.rootSpanId;
275
+ if (!this.rowId) {
276
+ throw new Error("rowId must be nonempty string");
277
+ }
278
+ if (!this.spanId) {
279
+ throw new Error("spanId must be nonempty string");
280
+ }
281
+ if (!this.rootSpanId) {
282
+ throw new Error("rootSpanId must be nonempty string");
283
+ }
284
+ }
285
+ toObject() {
286
+ return {
287
+ rowId: this.rowId,
288
+ spanId: this.spanId,
289
+ rootSpanId: this.rootSpanId
290
+ };
291
+ }
292
+ };
293
+ var SpanComponentsV2 = class _SpanComponentsV2 {
294
+ objectType;
295
+ objectId;
296
+ computeObjectMetadataArgs;
297
+ rowIds;
298
+ constructor(args) {
299
+ this.objectType = args.objectType;
300
+ this.objectId = args.objectId;
301
+ this.computeObjectMetadataArgs = args.computeObjectMetadataArgs;
302
+ this.rowIds = args.rowIds;
303
+ if (!(this.objectId || this.computeObjectMetadataArgs)) {
304
+ throw new Error(
305
+ "Must provide either objectId or computeObjectMetadataArgs"
306
+ );
307
+ }
308
+ }
309
+ toStr() {
310
+ const allBuffers = [];
311
+ const { bytes: rowIdBytes, isUUID: rowIdIsUUID } = this.rowIds ? tryMakeUuid2(this.rowIds.rowId) : { bytes: Buffer.from(""), isUUID: false };
312
+ allBuffers.push(
313
+ Buffer.from([
314
+ ENCODING_VERSION_NUMBER2,
315
+ this.objectType,
316
+ this.objectId ? 1 : 0,
317
+ this.computeObjectMetadataArgs ? 1 : 0,
318
+ this.rowIds ? 1 : 0,
319
+ rowIdIsUUID ? 1 : 0
320
+ ])
321
+ );
322
+ if (this.objectId) {
323
+ const { bytes: objectIdBytes, isUUID: objectIdIsUUID } = tryMakeUuid2(
324
+ this.objectId
325
+ );
326
+ if (!objectIdIsUUID) {
327
+ throw new Error("object_id component must be a valid UUID");
328
+ }
329
+ allBuffers.push(objectIdBytes);
330
+ }
331
+ if (this.computeObjectMetadataArgs) {
332
+ const computeObjectMetadataBytes = Buffer.from(
333
+ JSON.stringify(this.computeObjectMetadataArgs),
334
+ "utf-8"
335
+ );
336
+ const serializedLenBytes = Buffer.alloc(INTEGER_ENCODING_NUM_BYTES);
337
+ serializedLenBytes.writeInt32BE(computeObjectMetadataBytes.length);
338
+ allBuffers.push(serializedLenBytes, computeObjectMetadataBytes);
339
+ }
340
+ if (this.rowIds) {
341
+ const { bytes: spanIdBytes, isUUID: spanIdIsUUID } = tryMakeUuid2(
342
+ this.rowIds.spanId
343
+ );
344
+ if (!spanIdIsUUID) {
345
+ throw new Error("span_id component must be a valid UUID");
346
+ }
347
+ const { bytes: rootSpanIdBytes, isUUID: rootSpanIdIsUUID } = tryMakeUuid2(
348
+ this.rowIds.rootSpanId
349
+ );
350
+ if (!rootSpanIdIsUUID) {
351
+ throw new Error("root_span_id component must be a valid UUID");
352
+ }
353
+ allBuffers.push(spanIdBytes, rootSpanIdBytes, rowIdBytes);
354
+ }
355
+ return Buffer.concat(allBuffers).toString("base64");
356
+ }
357
+ static fromStr(s) {
358
+ try {
359
+ const rawBytes = Buffer.from(s, "base64");
360
+ if (rawBytes[0] < ENCODING_VERSION_NUMBER2) {
361
+ const spanComponentsOld = SpanComponentsV1.fromStr(s);
362
+ return new _SpanComponentsV2({
363
+ objectType: SpanObjectTypeV2EnumSchema.parse(
364
+ spanComponentsOld.objectType
365
+ ),
366
+ objectId: spanComponentsOld.objectId,
367
+ rowIds: spanComponentsOld.rowIds ? new SpanRowIdsV2({
368
+ rowId: spanComponentsOld.rowIds.rowId,
369
+ spanId: spanComponentsOld.rowIds.spanId,
370
+ rootSpanId: spanComponentsOld.rowIds.rootSpanId
371
+ }) : void 0
372
+ });
373
+ }
374
+ if (rawBytes[0] !== ENCODING_VERSION_NUMBER2) {
375
+ throw new Error();
376
+ }
377
+ const objectType = SpanObjectTypeV2EnumSchema.parse(rawBytes[1]);
378
+ for (let i = 2; i < 6; ++i) {
379
+ if (![0, 1].includes(rawBytes[i])) {
380
+ throw new Error();
381
+ }
382
+ }
383
+ const hasObjectId = rawBytes[2] == 1;
384
+ const hasComputeObjectMetadataArgs = rawBytes[3] == 1;
385
+ const hasRowId = rawBytes[4] == 1;
386
+ const rowIdIsUUID = rawBytes[5] == 1;
387
+ let byteCursor = 6;
388
+ let objectId = void 0;
389
+ if (hasObjectId) {
390
+ const nextByteCursor = byteCursor + 16;
391
+ objectId = uuid2.stringify(
392
+ rawBytes.subarray(byteCursor, nextByteCursor)
393
+ );
394
+ byteCursor = nextByteCursor;
395
+ }
396
+ let computeObjectMetadataArgs;
397
+ if (hasComputeObjectMetadataArgs) {
398
+ let nextByteCursor = byteCursor + INTEGER_ENCODING_NUM_BYTES;
399
+ const serializedLenBytes = rawBytes.readInt32BE(byteCursor);
400
+ byteCursor = nextByteCursor;
401
+ nextByteCursor = byteCursor + serializedLenBytes;
402
+ computeObjectMetadataArgs = JSON.parse(
403
+ rawBytes.subarray(byteCursor, nextByteCursor).toString("utf-8")
404
+ );
405
+ byteCursor = nextByteCursor;
406
+ }
407
+ const rowIds = (() => {
408
+ if (!hasRowId) {
409
+ return void 0;
410
+ }
411
+ let nextByteCursor = byteCursor + 16;
412
+ const spanId = uuid2.stringify(
413
+ rawBytes.subarray(byteCursor, nextByteCursor)
414
+ );
415
+ byteCursor = nextByteCursor;
416
+ nextByteCursor = byteCursor + 16;
417
+ const rootSpanId = uuid2.stringify(
418
+ rawBytes.subarray(byteCursor, nextByteCursor)
419
+ );
420
+ byteCursor = nextByteCursor;
421
+ const rowId = rowIdIsUUID ? uuid2.stringify(rawBytes.subarray(byteCursor)) : rawBytes.subarray(byteCursor).toString("utf-8");
422
+ return new SpanRowIdsV2({ rowId, spanId, rootSpanId });
423
+ })();
424
+ return new _SpanComponentsV2({
425
+ objectType,
426
+ objectId,
427
+ computeObjectMetadataArgs,
428
+ rowIds
429
+ });
430
+ } catch (e) {
431
+ throw new Error(INVALID_ENCODING_ERRMSG2);
432
+ }
433
+ }
434
+ objectIdFields() {
435
+ if (!this.objectId) {
436
+ throw new Error(
437
+ "Impossible: cannot invoke `object_id_fields` unless SpanComponentsV2 is initialized with an `object_id`"
438
+ );
439
+ }
440
+ switch (this.objectType) {
441
+ case 1 /* EXPERIMENT */:
442
+ return { experiment_id: this.objectId };
443
+ case 2 /* PROJECT_LOGS */:
444
+ return { project_id: this.objectId, log_id: "g" };
445
+ default:
446
+ throw new Error("Impossible");
447
+ }
448
+ }
449
+ toObject() {
450
+ return {
451
+ objectType: this.objectType,
452
+ objectId: this.objectId,
453
+ computeObjectMetadataArgs: this.computeObjectMetadataArgs,
454
+ rowIds: this.rowIds?.toObject()
455
+ };
456
+ }
457
+ };
458
+
459
+ // util/span_identifier_v3.ts
460
+ import { z as z3 } from "zod/v3";
461
+
462
+ // util/bytes.ts
463
+ function concatUint8Arrays(...arrays) {
464
+ const totalLength = arrays.reduce((acc, arr) => acc + arr.length, 0);
465
+ const result = new Uint8Array(totalLength);
466
+ let offset = 0;
467
+ for (const arr of arrays) {
468
+ result.set(arr, offset);
469
+ offset += arr.length;
470
+ }
471
+ return result;
472
+ }
473
+ function uint8ArrayToBase64(uint8Array) {
474
+ let binary = "";
475
+ for (let i = 0; i < uint8Array.length; i++) {
476
+ binary += String.fromCharCode(uint8Array[i]);
477
+ }
478
+ return btoa(binary);
479
+ }
480
+ function base64ToUint8Array(base64) {
481
+ const binary = atob(base64);
482
+ const uint8Array = new Uint8Array(binary.length);
483
+ for (let i = 0; i < binary.length; i++) {
484
+ uint8Array[i] = binary.charCodeAt(i);
485
+ }
486
+ return uint8Array;
487
+ }
488
+ function uint8ArrayToString(uint8Array) {
489
+ const decoder = new TextDecoder("utf-8");
490
+ return decoder.decode(uint8Array);
491
+ }
492
+ function stringToUint8Array(str) {
493
+ const encoder = new TextEncoder();
494
+ return encoder.encode(str);
495
+ }
496
+
497
+ // util/span_identifier_v3.ts
498
+ function tryMakeUuid3(s) {
499
+ try {
500
+ const ret = uuid3.parse(s);
501
+ if (ret.length !== 16) {
502
+ throw new Error();
503
+ }
504
+ return { bytes: new Uint8Array(ret), isUUID: true };
505
+ } catch {
506
+ return { bytes: void 0, isUUID: false };
507
+ }
508
+ }
509
+ var ENCODING_VERSION_NUMBER3 = 3;
510
+ 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.`;
511
+ var SpanObjectTypeV3 = /* @__PURE__ */ ((SpanObjectTypeV32) => {
512
+ SpanObjectTypeV32[SpanObjectTypeV32["EXPERIMENT"] = 1] = "EXPERIMENT";
513
+ SpanObjectTypeV32[SpanObjectTypeV32["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
514
+ SpanObjectTypeV32[SpanObjectTypeV32["PLAYGROUND_LOGS"] = 3] = "PLAYGROUND_LOGS";
515
+ return SpanObjectTypeV32;
516
+ })(SpanObjectTypeV3 || {});
517
+ var spanObjectTypeV3EnumSchema = z3.nativeEnum(SpanObjectTypeV3);
518
+ function spanObjectTypeV3ToString(objectType) {
519
+ switch (objectType) {
520
+ case 1 /* EXPERIMENT */:
521
+ return "experiment";
522
+ case 2 /* PROJECT_LOGS */:
523
+ return "project_logs";
524
+ case 3 /* PLAYGROUND_LOGS */:
525
+ return "playground_logs";
526
+ default:
527
+ const x = objectType;
528
+ throw new Error(`Unknown SpanObjectTypeV3: ${x}`);
529
+ }
530
+ }
531
+ var InternalSpanComponentUUIDFields = /* @__PURE__ */ ((InternalSpanComponentUUIDFields2) => {
532
+ InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["OBJECT_ID"] = 1] = "OBJECT_ID";
533
+ InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["ROW_ID"] = 2] = "ROW_ID";
534
+ InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["SPAN_ID"] = 3] = "SPAN_ID";
535
+ InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["ROOT_SPAN_ID"] = 4] = "ROOT_SPAN_ID";
536
+ return InternalSpanComponentUUIDFields2;
537
+ })(InternalSpanComponentUUIDFields || {});
538
+ var internalSpanComponentUUIDFieldsEnumSchema = z3.nativeEnum(
539
+ InternalSpanComponentUUIDFields
540
+ );
541
+ var _INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME = {
542
+ [1 /* OBJECT_ID */]: "object_id",
543
+ [2 /* ROW_ID */]: "row_id",
544
+ [3 /* SPAN_ID */]: "span_id",
545
+ [4 /* ROOT_SPAN_ID */]: "root_span_id"
546
+ };
547
+ var spanComponentsV3Schema = z3.object({
548
+ object_type: spanObjectTypeV3EnumSchema,
549
+ // TODO(manu): We should have a more elaborate zod schema for
550
+ // `propagated_event`. This will required zod-ifying the contents of
551
+ // sdk/js/util/object.ts.
552
+ propagated_event: z3.record(z3.unknown()).nullish()
553
+ }).and(
554
+ z3.union([
555
+ // Must provide one or the other.
556
+ z3.object({
557
+ object_id: z3.string().nullish(),
558
+ compute_object_metadata_args: z3.optional(z3.null())
559
+ }),
560
+ z3.object({
561
+ object_id: z3.optional(z3.null()),
562
+ compute_object_metadata_args: z3.record(z3.unknown())
563
+ })
564
+ ])
565
+ ).and(
566
+ z3.union([
567
+ // Either all of these must be provided or none.
568
+ z3.object({
569
+ row_id: z3.string(),
570
+ span_id: z3.string(),
571
+ root_span_id: z3.string()
572
+ }),
573
+ z3.object({
574
+ row_id: z3.optional(z3.null()),
575
+ span_id: z3.optional(z3.null()),
576
+ root_span_id: z3.optional(z3.null())
577
+ })
578
+ ])
579
+ );
580
+ var SpanComponentsV3 = class _SpanComponentsV3 {
581
+ constructor(data) {
582
+ this.data = data;
583
+ }
584
+ toStr() {
585
+ const jsonObj = {
586
+ compute_object_metadata_args: this.data.compute_object_metadata_args || void 0,
587
+ propagated_event: this.data.propagated_event || void 0
588
+ };
589
+ const allBuffers = [];
590
+ allBuffers.push(
591
+ new Uint8Array([ENCODING_VERSION_NUMBER3, this.data.object_type])
592
+ );
593
+ const uuidEntries = [];
594
+ function addUuidField(origVal, fieldId) {
595
+ const ret = tryMakeUuid3(origVal);
596
+ if (ret.isUUID) {
597
+ uuidEntries.push(
598
+ concatUint8Arrays(new Uint8Array([fieldId]), ret.bytes)
599
+ );
600
+ } else {
601
+ jsonObj[_INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME[fieldId]] = origVal;
602
+ }
603
+ }
604
+ if (this.data.object_id) {
605
+ addUuidField(
606
+ this.data.object_id,
607
+ 1 /* OBJECT_ID */
608
+ );
609
+ }
610
+ if (this.data.row_id) {
611
+ addUuidField(this.data.row_id, 2 /* ROW_ID */);
612
+ }
613
+ if (this.data.span_id) {
614
+ addUuidField(this.data.span_id, 3 /* SPAN_ID */);
615
+ }
616
+ if (this.data.root_span_id) {
617
+ addUuidField(
618
+ this.data.root_span_id,
619
+ 4 /* ROOT_SPAN_ID */
620
+ );
621
+ }
622
+ if (uuidEntries.length > 255) {
623
+ throw new Error("Impossible: too many UUID entries to encode");
624
+ }
625
+ allBuffers.push(new Uint8Array([uuidEntries.length]));
626
+ allBuffers.push(...uuidEntries);
627
+ if (Object.keys(jsonObj).length > 0) {
628
+ allBuffers.push(stringToUint8Array(JSON.stringify(jsonObj)));
629
+ }
630
+ return uint8ArrayToBase64(concatUint8Arrays(...allBuffers));
631
+ }
632
+ static fromStr(s) {
633
+ try {
634
+ const rawBytes = base64ToUint8Array(s);
635
+ const jsonObj = {};
636
+ if (rawBytes[0] < ENCODING_VERSION_NUMBER3) {
637
+ const spanComponentsOld = SpanComponentsV2.fromStr(s);
638
+ jsonObj["object_type"] = spanComponentsOld.objectType;
639
+ jsonObj["object_id"] = spanComponentsOld.objectId;
640
+ jsonObj["compute_object_metadata_args"] = spanComponentsOld.computeObjectMetadataArgs;
641
+ if (spanComponentsOld.rowIds) {
642
+ jsonObj["row_id"] = spanComponentsOld.rowIds.rowId;
643
+ jsonObj["span_id"] = spanComponentsOld.rowIds.spanId;
644
+ jsonObj["root_span_id"] = spanComponentsOld.rowIds.rootSpanId;
645
+ }
646
+ } else {
647
+ jsonObj["object_type"] = rawBytes[1];
648
+ const numUuidEntries = rawBytes[2];
649
+ let byteOffset = 3;
650
+ for (let i = 0; i < numUuidEntries; ++i) {
651
+ const fieldId = internalSpanComponentUUIDFieldsEnumSchema.parse(
652
+ rawBytes[byteOffset]
653
+ );
654
+ const fieldBytes = rawBytes.subarray(byteOffset + 1, byteOffset + 17);
655
+ byteOffset += 17;
656
+ jsonObj[_INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME[fieldId]] = uuid3.stringify(fieldBytes);
657
+ }
658
+ if (byteOffset < rawBytes.length) {
659
+ const remainingJsonObj = JSON.parse(
660
+ uint8ArrayToString(rawBytes.subarray(byteOffset))
661
+ );
662
+ Object.assign(jsonObj, remainingJsonObj);
663
+ }
664
+ }
665
+ return _SpanComponentsV3.fromJsonObj(jsonObj);
666
+ } catch {
667
+ throw new Error(INVALID_ENCODING_ERRMSG3);
668
+ }
669
+ }
670
+ objectIdFields() {
671
+ if (!this.data.object_id) {
672
+ throw new Error(
673
+ "Impossible: cannot invoke `objectIdFields` unless SpanComponentsV3 is initialized with an `object_id`"
674
+ );
675
+ }
676
+ switch (this.data.object_type) {
677
+ case 1 /* EXPERIMENT */:
678
+ return { experiment_id: this.data.object_id };
679
+ case 2 /* PROJECT_LOGS */:
680
+ return { project_id: this.data.object_id, log_id: "g" };
681
+ case 3 /* PLAYGROUND_LOGS */:
682
+ return { prompt_session_id: this.data.object_id, log_id: "x" };
683
+ default:
684
+ const _ = this.data.object_type;
685
+ throw new Error("Impossible");
686
+ }
687
+ }
688
+ async export() {
689
+ return this.toStr();
690
+ }
691
+ static fromJsonObj(jsonObj) {
692
+ return new _SpanComponentsV3(spanComponentsV3Schema.parse(jsonObj));
693
+ }
694
+ };
695
+
696
+ // util/type_util.ts
697
+ function isObject(value) {
698
+ return value instanceof Object && !(value instanceof Array);
699
+ }
700
+ function isArray(value) {
701
+ return value instanceof Array;
702
+ }
703
+ function isObjectOrArray(value) {
704
+ return value instanceof Object;
705
+ }
706
+
707
+ // util/object_util.ts
708
+ function mergeDictsWithPaths({
709
+ mergeInto,
710
+ mergeFrom,
711
+ mergePaths
712
+ }) {
713
+ const mergePathsSerialized = new Set(
714
+ mergePaths.map((p) => JSON.stringify(p))
715
+ );
716
+ return mergeDictsWithPathsHelper({
717
+ mergeInto,
718
+ mergeFrom,
719
+ path: [],
720
+ mergePaths: mergePathsSerialized
721
+ });
722
+ }
723
+ function mergeDictsWithPathsHelper({
724
+ mergeInto,
725
+ mergeFrom,
726
+ path,
727
+ mergePaths
728
+ }) {
729
+ Object.entries(mergeFrom).forEach(([k, mergeFromV]) => {
730
+ const fullPath = path.concat([k]);
731
+ const fullPathSerialized = JSON.stringify(fullPath);
732
+ const mergeIntoV = recordFind(mergeInto, k);
733
+ if (isObject(mergeIntoV) && isObject(mergeFromV) && !mergePaths.has(fullPathSerialized)) {
734
+ mergeDictsWithPathsHelper({
735
+ mergeInto: mergeIntoV,
736
+ mergeFrom: mergeFromV,
737
+ path: fullPath,
738
+ mergePaths
739
+ });
740
+ } else {
741
+ mergeInto[k] = mergeFromV;
742
+ }
743
+ });
744
+ return mergeInto;
745
+ }
746
+ function mergeDicts(mergeInto, mergeFrom) {
747
+ return mergeDictsWithPaths({ mergeInto, mergeFrom, mergePaths: [] });
748
+ }
749
+ function mapAt(m, k) {
750
+ const ret = m.get(k);
751
+ if (ret === void 0) {
752
+ throw new Error(`Map does not contain key ${k}`);
753
+ }
754
+ return ret;
755
+ }
756
+ function recordFind(m, k) {
757
+ return m[k];
758
+ }
759
+ function getObjValueByPath(row, path) {
760
+ let curr = row;
761
+ for (const p of path) {
762
+ if (!isObjectOrArray(curr)) {
763
+ return null;
764
+ }
765
+ curr = curr[p];
766
+ }
767
+ return curr;
768
+ }
769
+
770
+ // util/graph_util.ts
771
+ function depthFirstSearch(args) {
772
+ const { graph, firstVisitF, lastVisitF } = args;
773
+ for (const vs of graph.values()) {
774
+ for (const v of vs.values()) {
775
+ if (!graph.has(v)) {
776
+ throw new Error(`Outgoing vertex ${v} must be a key in the graph`);
777
+ }
778
+ }
779
+ }
780
+ const firstVisitedVertices = /* @__PURE__ */ new Set();
781
+ const visitationOrder = args.visitationOrder ?? [...graph.keys()];
782
+ const events = visitationOrder.map((vertex) => ({ eventType: "first", vertex, extras: {} })).reverse();
783
+ while (events.length) {
784
+ const { eventType, vertex, extras } = events.pop();
785
+ if (eventType === "last") {
786
+ lastVisitF?.(vertex);
787
+ continue;
788
+ }
789
+ if (firstVisitedVertices.has(vertex)) {
790
+ continue;
791
+ }
792
+ firstVisitedVertices.add(vertex);
793
+ firstVisitF?.(vertex, { parentVertex: extras.parentVertex });
794
+ events.push({ eventType: "last", vertex, extras: {} });
795
+ mapAt(graph, vertex).forEach((child) => {
796
+ events.push({
797
+ eventType: "first",
798
+ vertex: child,
799
+ extras: { parentVertex: vertex }
800
+ });
801
+ });
802
+ }
803
+ }
804
+ function undirectedConnectedComponents(graph) {
805
+ const directedGraph = new Map(
806
+ [...graph.vertices].map((v) => [v, /* @__PURE__ */ new Set()])
807
+ );
808
+ for (const [i, j] of graph.edges) {
809
+ mapAt(directedGraph, i).add(j);
810
+ mapAt(directedGraph, j).add(i);
811
+ }
812
+ let labelCounter = 0;
813
+ const vertexLabels = /* @__PURE__ */ new Map();
814
+ const firstVisitF = (vertex, args) => {
815
+ const label = args?.parentVertex !== void 0 ? mapAt(vertexLabels, args?.parentVertex) : labelCounter++;
816
+ vertexLabels.set(vertex, label);
817
+ };
818
+ depthFirstSearch({ graph: directedGraph, firstVisitF });
819
+ const output = Array.from({ length: labelCounter }).map(() => []);
820
+ for (const [vertex, label] of vertexLabels.entries()) {
821
+ output[label].push(vertex);
822
+ }
823
+ return output;
824
+ }
825
+ function topologicalSort(graph, visitationOrder) {
826
+ const reverseOrdering = [];
827
+ const lastVisitF = (vertex) => {
828
+ reverseOrdering.push(vertex);
829
+ };
830
+ depthFirstSearch({ graph, lastVisitF, visitationOrder });
831
+ return reverseOrdering.reverse();
832
+ }
833
+
834
+ // util/merge_row_batch.ts
835
+ function generateMergedRowKey(row, useParentIdForId) {
836
+ return JSON.stringify(
837
+ [
838
+ "org_id",
839
+ "project_id",
840
+ "experiment_id",
841
+ "dataset_id",
842
+ "prompt_session_id",
843
+ "log_id",
844
+ useParentIdForId ?? false ? PARENT_ID_FIELD : "id"
845
+ ].map((k) => row[k])
846
+ );
847
+ }
848
+ var MERGE_ROW_SKIP_FIELDS = [
849
+ "created",
850
+ "span_id",
851
+ "root_span_id",
852
+ "span_parents",
853
+ "_parent_id"
854
+ // TODO: handle merge paths.
855
+ ];
856
+ function popMergeRowSkipFields(row) {
857
+ const popped = {};
858
+ for (const field of MERGE_ROW_SKIP_FIELDS) {
859
+ if (field in row) {
860
+ popped[field] = row[field];
861
+ delete row[field];
862
+ }
863
+ }
864
+ return popped;
865
+ }
866
+ function restoreMergeRowSkipFields(row, skipFields) {
867
+ for (const field of MERGE_ROW_SKIP_FIELDS) {
868
+ delete row[field];
869
+ if (field in skipFields) {
870
+ row[field] = skipFields[field];
871
+ }
872
+ }
873
+ }
874
+ function mergeRowBatch(rows) {
875
+ for (const row of rows) {
876
+ if (row.id === void 0) {
877
+ throw new Error(
878
+ "Logged row is missing an id. This is an internal braintrust error. Please contact us at info@braintrust.dev for help"
879
+ );
880
+ }
881
+ }
882
+ const rowGroups = /* @__PURE__ */ new Map();
883
+ for (const row of rows) {
884
+ const key = generateMergedRowKey(row);
885
+ const existingRow = rowGroups.get(key);
886
+ if (existingRow !== void 0 && row[IS_MERGE_FIELD]) {
887
+ const skipFields = popMergeRowSkipFields(existingRow);
888
+ const preserveNoMerge = !existingRow[IS_MERGE_FIELD];
889
+ mergeDicts(existingRow, row);
890
+ restoreMergeRowSkipFields(existingRow, skipFields);
891
+ if (preserveNoMerge) {
892
+ delete existingRow[IS_MERGE_FIELD];
893
+ }
894
+ } else {
895
+ rowGroups.set(key, row);
896
+ }
897
+ }
898
+ const merged = [...rowGroups.values()];
899
+ const rowToLabel = new Map(
900
+ merged.map((r, i) => [generateMergedRowKey(r), i])
901
+ );
902
+ const graph = new Map(
903
+ Array.from({ length: merged.length }).map((_, i) => [i, /* @__PURE__ */ new Set()])
904
+ );
905
+ merged.forEach((r, i) => {
906
+ const parentId = r[PARENT_ID_FIELD];
907
+ if (!parentId) {
908
+ return;
909
+ }
910
+ const parentRowKey = generateMergedRowKey(
911
+ r,
912
+ true
913
+ /* useParentIdForId */
914
+ );
915
+ const parentLabel = rowToLabel.get(parentRowKey);
916
+ if (parentLabel !== void 0) {
917
+ mapAt(graph, parentLabel).add(i);
918
+ }
919
+ });
920
+ const connectedComponents = undirectedConnectedComponents({
921
+ vertices: new Set(graph.keys()),
922
+ edges: new Set(
923
+ [...graph.entries()].flatMap(
924
+ ([k, vs]) => [...vs].map((v) => {
925
+ const ret = [k, v];
926
+ return ret;
927
+ })
928
+ )
929
+ )
930
+ });
931
+ const buckets = connectedComponents.map(
932
+ (cc) => topologicalSort(
933
+ graph,
934
+ cc
935
+ /* visitationOrder */
936
+ )
937
+ );
938
+ return buckets.map((bucket) => bucket.map((i) => merged[i]));
939
+ }
940
+ function batchItems(args) {
941
+ let { items } = args;
942
+ const batchMaxNumItems = args.batchMaxNumItems ?? Number.POSITIVE_INFINITY;
943
+ const batchMaxNumBytes = args.batchMaxNumBytes ?? Number.POSITIVE_INFINITY;
944
+ const output = [];
945
+ let nextItems = [];
946
+ let batchSet = [];
947
+ let batch = [];
948
+ let batchLen = 0;
949
+ function addToBatch(item) {
950
+ batch.push(item);
951
+ batchLen += item.length;
952
+ }
953
+ function flushBatch() {
954
+ batchSet.push(batch);
955
+ batch = [];
956
+ batchLen = 0;
957
+ }
958
+ while (items.length) {
959
+ for (const bucket of items) {
960
+ let i = 0;
961
+ for (const item of bucket) {
962
+ if (batch.length === 0 || item.length + batchLen < batchMaxNumBytes && batch.length < batchMaxNumItems) {
963
+ addToBatch(item);
964
+ } else if (i === 0) {
965
+ flushBatch();
966
+ addToBatch(item);
967
+ } else {
968
+ break;
969
+ }
970
+ ++i;
971
+ }
972
+ if (i < bucket.length) {
973
+ nextItems.push(bucket.slice(i));
974
+ }
975
+ if (batchLen >= batchMaxNumBytes || batch.length > batchMaxNumItems) {
976
+ flushBatch();
977
+ }
978
+ }
979
+ if (batch.length) {
980
+ flushBatch();
981
+ }
982
+ if (batchSet.length) {
983
+ output.push(batchSet);
984
+ batchSet = [];
985
+ }
986
+ items = nextItems;
987
+ nextItems = [];
988
+ }
989
+ return output;
990
+ }
991
+
992
+ // util/object.ts
993
+ var DEFAULT_IS_LEGACY_DATASET = false;
994
+ function ensureDatasetRecord(r, legacy) {
995
+ if (legacy) {
996
+ return ensureLegacyDatasetRecord(r);
997
+ } else {
998
+ return ensureNewDatasetRecord(r);
999
+ }
1000
+ }
1001
+ function ensureLegacyDatasetRecord(r) {
1002
+ if ("output" in r) {
1003
+ return r;
1004
+ }
1005
+ const row = {
1006
+ ...r,
1007
+ output: r.expected
1008
+ };
1009
+ delete row.expected;
1010
+ return row;
1011
+ }
1012
+ function ensureNewDatasetRecord(r) {
1013
+ if ("expected" in r) {
1014
+ return r;
1015
+ }
1016
+ const row = {
1017
+ ...r,
1018
+ tags: null,
1019
+ expected: r.output
1020
+ };
1021
+ delete row.output;
1022
+ return row;
1023
+ }
1024
+
1025
+ // util/json_util.ts
1026
+ function constructJsonArray(items) {
1027
+ return `[${items.join(",")}]`;
1028
+ }
1029
+
1030
+ // util/string_util.ts
1031
+ function _urljoin(...parts) {
1032
+ return parts.map(
1033
+ (x, i) => x.replace(/^\//, "").replace(i < parts.length - 1 ? /\/$/ : "", "")
1034
+ ).filter((x) => x.trim() !== "").join("/");
1035
+ }
1036
+
1037
+ // util/git_fields.ts
1038
+ function mergeGitMetadataSettings(s1, s2) {
1039
+ if (s1.collect === "all") {
1040
+ return s2;
1041
+ } else if (s2.collect === "all") {
1042
+ return s1;
1043
+ } else if (s1.collect === "none") {
1044
+ return s1;
1045
+ } else if (s2.collect === "none") {
1046
+ return s2;
1047
+ }
1048
+ const fields = (s1.fields ?? []).filter((f) => (s2.fields ?? []).includes(f));
1049
+ const collect = fields.length > 0 ? "some" : "none";
1050
+ return { collect, fields };
1051
+ }
1052
+
1053
+ // util/xact-ids.ts
1054
+ var TOP_BITS = BigInt("0x0DE1") << BigInt(48);
1055
+ var MOD = BigInt(1) << BigInt(64);
1056
+ var COPRIME = BigInt("205891132094649");
1057
+ var COPRIME_INVERSE = BigInt("1522336535492693385");
1058
+ function modularMultiply(value, prime) {
1059
+ return value * prime % MOD;
1060
+ }
1061
+ function prettifyXact(valueString) {
1062
+ const value = BigInt(valueString);
1063
+ const encoded = modularMultiply(value, COPRIME);
1064
+ return encoded.toString(16).padStart(16, "0");
1065
+ }
1066
+
1067
+ // util/zod_util.ts
1068
+ import { z as z4 } from "zod/v3";
112
1069
 
113
1070
  // src/generated_types.ts
114
- import { z } from "zod";
115
- var AclObjectType = z.union([
116
- z.enum([
1071
+ import { z as z5 } from "zod/v3";
1072
+ var AclObjectType = z5.union([
1073
+ z5.enum([
117
1074
  "organization",
118
1075
  "project",
119
1076
  "experiment",
@@ -126,9 +1083,9 @@ var AclObjectType = z.union([
126
1083
  "project_log",
127
1084
  "org_project"
128
1085
  ]),
129
- z.null()
1086
+ z5.null()
130
1087
  ]);
131
- var Permission = z.enum([
1088
+ var Permission = z5.enum([
132
1089
  "create",
133
1090
  "read",
134
1091
  "update",
@@ -138,310 +1095,310 @@ var Permission = z.enum([
138
1095
  "update_acls",
139
1096
  "delete_acls"
140
1097
  ]);
141
- var Acl = z.object({
142
- id: z.string().uuid(),
143
- object_type: AclObjectType.and(z.string()),
144
- object_id: z.string().uuid(),
145
- user_id: z.union([z.string(), z.null()]).optional(),
146
- group_id: z.union([z.string(), z.null()]).optional(),
147
- permission: Permission.and(z.union([z.string(), z.null()])).optional(),
148
- restrict_object_type: AclObjectType.and(z.unknown()).optional(),
149
- role_id: z.union([z.string(), z.null()]).optional(),
150
- _object_org_id: z.string().uuid(),
151
- created: z.union([z.string(), z.null()]).optional()
1098
+ var Acl = z5.object({
1099
+ id: z5.string().uuid(),
1100
+ object_type: AclObjectType.and(z5.string()),
1101
+ object_id: z5.string().uuid(),
1102
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
1103
+ group_id: z5.union([z5.string(), z5.null()]).optional(),
1104
+ permission: Permission.and(z5.union([z5.string(), z5.null()])).optional(),
1105
+ restrict_object_type: AclObjectType.and(z5.unknown()).optional(),
1106
+ role_id: z5.union([z5.string(), z5.null()]).optional(),
1107
+ _object_org_id: z5.string().uuid(),
1108
+ created: z5.union([z5.string(), z5.null()]).optional()
152
1109
  });
153
- var AISecret = z.object({
154
- id: z.string().uuid(),
155
- created: z.union([z.string(), z.null()]).optional(),
156
- updated_at: z.union([z.string(), z.null()]).optional(),
157
- org_id: z.string().uuid(),
158
- name: z.string(),
159
- type: z.union([z.string(), z.null()]).optional(),
160
- metadata: z.union([z.object({}).partial().passthrough(), z.null()]).optional(),
161
- preview_secret: z.union([z.string(), z.null()]).optional()
1110
+ var AISecret = z5.object({
1111
+ id: z5.string().uuid(),
1112
+ created: z5.union([z5.string(), z5.null()]).optional(),
1113
+ updated_at: z5.union([z5.string(), z5.null()]).optional(),
1114
+ org_id: z5.string().uuid(),
1115
+ name: z5.string(),
1116
+ type: z5.union([z5.string(), z5.null()]).optional(),
1117
+ metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
1118
+ preview_secret: z5.union([z5.string(), z5.null()]).optional()
162
1119
  });
163
- var ResponseFormatJsonSchema = z.object({
164
- name: z.string(),
165
- description: z.string().optional(),
166
- schema: z.union([z.object({}).partial().passthrough(), z.string()]).optional(),
167
- strict: z.union([z.boolean(), z.null()]).optional()
1120
+ var ResponseFormatJsonSchema = z5.object({
1121
+ name: z5.string(),
1122
+ description: z5.string().optional(),
1123
+ schema: z5.union([z5.object({}).partial().passthrough(), z5.string()]).optional(),
1124
+ strict: z5.union([z5.boolean(), z5.null()]).optional()
168
1125
  });
169
- var ResponseFormatNullish = z.union([
170
- z.object({ type: z.literal("json_object") }),
171
- z.object({
172
- type: z.literal("json_schema"),
1126
+ var ResponseFormatNullish = z5.union([
1127
+ z5.object({ type: z5.literal("json_object") }),
1128
+ z5.object({
1129
+ type: z5.literal("json_schema"),
173
1130
  json_schema: ResponseFormatJsonSchema
174
1131
  }),
175
- z.object({ type: z.literal("text") }),
176
- z.null()
1132
+ z5.object({ type: z5.literal("text") }),
1133
+ z5.null()
177
1134
  ]);
178
- var AnyModelParams = z.object({
179
- temperature: z.number().optional(),
180
- top_p: z.number().optional(),
181
- max_tokens: z.number(),
182
- max_completion_tokens: z.number().optional(),
183
- frequency_penalty: z.number().optional(),
184
- presence_penalty: z.number().optional(),
1135
+ var AnyModelParams = z5.object({
1136
+ temperature: z5.number().optional(),
1137
+ top_p: z5.number().optional(),
1138
+ max_tokens: z5.number(),
1139
+ max_completion_tokens: z5.number().optional(),
1140
+ frequency_penalty: z5.number().optional(),
1141
+ presence_penalty: z5.number().optional(),
185
1142
  response_format: ResponseFormatNullish.optional(),
186
- tool_choice: z.union([
187
- z.literal("auto"),
188
- z.literal("none"),
189
- z.literal("required"),
190
- z.object({
191
- type: z.literal("function"),
192
- function: z.object({ name: z.string() })
1143
+ tool_choice: z5.union([
1144
+ z5.literal("auto"),
1145
+ z5.literal("none"),
1146
+ z5.literal("required"),
1147
+ z5.object({
1148
+ type: z5.literal("function"),
1149
+ function: z5.object({ name: z5.string() })
193
1150
  })
194
1151
  ]).optional(),
195
- function_call: z.union([
196
- z.literal("auto"),
197
- z.literal("none"),
198
- z.object({ name: z.string() })
1152
+ function_call: z5.union([
1153
+ z5.literal("auto"),
1154
+ z5.literal("none"),
1155
+ z5.object({ name: z5.string() })
199
1156
  ]).optional(),
200
- n: z.number().optional(),
201
- stop: z.array(z.string()).optional(),
202
- reasoning_effort: z.enum(["minimal", "low", "medium", "high"]).optional(),
203
- verbosity: z.enum(["low", "medium", "high"]).optional(),
204
- top_k: z.number().optional(),
205
- stop_sequences: z.array(z.string()).optional(),
206
- max_tokens_to_sample: z.number().optional(),
207
- maxOutputTokens: z.number().optional(),
208
- topP: z.number().optional(),
209
- topK: z.number().optional(),
210
- use_cache: z.boolean().optional()
1157
+ n: z5.number().optional(),
1158
+ stop: z5.array(z5.string()).optional(),
1159
+ reasoning_effort: z5.enum(["minimal", "low", "medium", "high"]).optional(),
1160
+ verbosity: z5.enum(["low", "medium", "high"]).optional(),
1161
+ top_k: z5.number().optional(),
1162
+ stop_sequences: z5.array(z5.string()).optional(),
1163
+ max_tokens_to_sample: z5.number().optional(),
1164
+ maxOutputTokens: z5.number().optional(),
1165
+ topP: z5.number().optional(),
1166
+ topK: z5.number().optional(),
1167
+ use_cache: z5.boolean().optional()
211
1168
  });
212
- var ApiKey = z.object({
213
- id: z.string().uuid(),
214
- created: z.union([z.string(), z.null()]).optional(),
215
- name: z.string(),
216
- preview_name: z.string(),
217
- user_id: z.union([z.string(), z.null()]).optional(),
218
- user_email: z.union([z.string(), z.null()]).optional(),
219
- user_given_name: z.union([z.string(), z.null()]).optional(),
220
- user_family_name: z.union([z.string(), z.null()]).optional(),
221
- org_id: z.union([z.string(), z.null()]).optional()
1169
+ var ApiKey = z5.object({
1170
+ id: z5.string().uuid(),
1171
+ created: z5.union([z5.string(), z5.null()]).optional(),
1172
+ name: z5.string(),
1173
+ preview_name: z5.string(),
1174
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
1175
+ user_email: z5.union([z5.string(), z5.null()]).optional(),
1176
+ user_given_name: z5.union([z5.string(), z5.null()]).optional(),
1177
+ user_family_name: z5.union([z5.string(), z5.null()]).optional(),
1178
+ org_id: z5.union([z5.string(), z5.null()]).optional()
222
1179
  });
223
- var AsyncScoringState = z.union([
224
- z.object({
225
- status: z.literal("enabled"),
226
- token: z.string(),
227
- function_ids: z.array(z.unknown()).min(1),
228
- skip_logging: z.union([z.boolean(), z.null()]).optional()
1180
+ var AsyncScoringState = z5.union([
1181
+ z5.object({
1182
+ status: z5.literal("enabled"),
1183
+ token: z5.string(),
1184
+ function_ids: z5.array(z5.unknown()).min(1),
1185
+ skip_logging: z5.union([z5.boolean(), z5.null()]).optional()
229
1186
  }),
230
- z.object({ status: z.literal("disabled") }),
231
- z.null(),
232
- z.null()
1187
+ z5.object({ status: z5.literal("disabled") }),
1188
+ z5.null(),
1189
+ z5.null()
233
1190
  ]);
234
- var AsyncScoringControl = z.union([
235
- z.object({ kind: z.literal("score_update"), token: z.string() }),
236
- z.object({ kind: z.literal("state_override"), state: AsyncScoringState }),
237
- z.object({ kind: z.literal("state_force_reselect") }),
238
- z.object({ kind: z.literal("state_enabled_force_rescore") })
1191
+ var AsyncScoringControl = z5.union([
1192
+ z5.object({ kind: z5.literal("score_update"), token: z5.string() }),
1193
+ z5.object({ kind: z5.literal("state_override"), state: AsyncScoringState }),
1194
+ z5.object({ kind: z5.literal("state_force_reselect") }),
1195
+ z5.object({ kind: z5.literal("state_enabled_force_rescore") })
239
1196
  ]);
240
- var BraintrustAttachmentReference = z.object({
241
- type: z.literal("braintrust_attachment"),
242
- filename: z.string().min(1),
243
- content_type: z.string().min(1),
244
- key: z.string().min(1)
1197
+ var BraintrustAttachmentReference = z5.object({
1198
+ type: z5.literal("braintrust_attachment"),
1199
+ filename: z5.string().min(1),
1200
+ content_type: z5.string().min(1),
1201
+ key: z5.string().min(1)
245
1202
  });
246
- var ExternalAttachmentReference = z.object({
247
- type: z.literal("external_attachment"),
248
- filename: z.string().min(1),
249
- content_type: z.string().min(1),
250
- url: z.string().min(1)
1203
+ var ExternalAttachmentReference = z5.object({
1204
+ type: z5.literal("external_attachment"),
1205
+ filename: z5.string().min(1),
1206
+ content_type: z5.string().min(1),
1207
+ url: z5.string().min(1)
251
1208
  });
252
- var AttachmentReference = z.discriminatedUnion("type", [
1209
+ var AttachmentReference = z5.discriminatedUnion("type", [
253
1210
  BraintrustAttachmentReference,
254
1211
  ExternalAttachmentReference
255
1212
  ]);
256
- var UploadStatus = z.enum(["uploading", "done", "error"]);
257
- var AttachmentStatus = z.object({
1213
+ var UploadStatus = z5.enum(["uploading", "done", "error"]);
1214
+ var AttachmentStatus = z5.object({
258
1215
  upload_status: UploadStatus,
259
- error_message: z.string().optional()
1216
+ error_message: z5.string().optional()
260
1217
  });
261
- var BraintrustModelParams = z.object({ use_cache: z.boolean() }).partial();
262
- var CallEvent = z.union([
263
- z.object({
264
- id: z.string().optional(),
265
- data: z.string(),
266
- event: z.literal("text_delta")
1218
+ var BraintrustModelParams = z5.object({ use_cache: z5.boolean() }).partial();
1219
+ var CallEvent = z5.union([
1220
+ z5.object({
1221
+ id: z5.string().optional(),
1222
+ data: z5.string(),
1223
+ event: z5.literal("text_delta")
267
1224
  }),
268
- z.object({
269
- id: z.string().optional(),
270
- data: z.string(),
271
- event: z.literal("reasoning_delta")
1225
+ z5.object({
1226
+ id: z5.string().optional(),
1227
+ data: z5.string(),
1228
+ event: z5.literal("reasoning_delta")
272
1229
  }),
273
- z.object({
274
- id: z.string().optional(),
275
- data: z.string(),
276
- event: z.literal("json_delta")
1230
+ z5.object({
1231
+ id: z5.string().optional(),
1232
+ data: z5.string(),
1233
+ event: z5.literal("json_delta")
277
1234
  }),
278
- z.object({
279
- id: z.string().optional(),
280
- data: z.string(),
281
- event: z.literal("progress")
1235
+ z5.object({
1236
+ id: z5.string().optional(),
1237
+ data: z5.string(),
1238
+ event: z5.literal("progress")
282
1239
  }),
283
- z.object({
284
- id: z.string().optional(),
285
- data: z.string(),
286
- event: z.literal("error")
1240
+ z5.object({
1241
+ id: z5.string().optional(),
1242
+ data: z5.string(),
1243
+ event: z5.literal("error")
287
1244
  }),
288
- z.object({
289
- id: z.string().optional(),
290
- data: z.string(),
291
- event: z.literal("console")
1245
+ z5.object({
1246
+ id: z5.string().optional(),
1247
+ data: z5.string(),
1248
+ event: z5.literal("console")
292
1249
  }),
293
- z.object({
294
- id: z.string().optional(),
295
- event: z.literal("start"),
296
- data: z.literal("")
1250
+ z5.object({
1251
+ id: z5.string().optional(),
1252
+ event: z5.literal("start"),
1253
+ data: z5.literal("")
297
1254
  }),
298
- z.object({
299
- id: z.string().optional(),
300
- event: z.literal("done"),
301
- data: z.literal("")
1255
+ z5.object({
1256
+ id: z5.string().optional(),
1257
+ event: z5.literal("done"),
1258
+ data: z5.literal("")
302
1259
  })
303
1260
  ]);
304
- var ChatCompletionContentPartTextWithTitle = z.object({
305
- text: z.string().default(""),
306
- type: z.literal("text"),
307
- cache_control: z.object({ type: z.literal("ephemeral") }).optional()
1261
+ var ChatCompletionContentPartTextWithTitle = z5.object({
1262
+ text: z5.string().default(""),
1263
+ type: z5.literal("text"),
1264
+ cache_control: z5.object({ type: z5.literal("ephemeral") }).optional()
308
1265
  });
309
- var ChatCompletionContentPartImageWithTitle = z.object({
310
- image_url: z.object({
311
- url: z.string(),
312
- detail: z.union([z.literal("auto"), z.literal("low"), z.literal("high")]).optional()
1266
+ var ChatCompletionContentPartImageWithTitle = z5.object({
1267
+ image_url: z5.object({
1268
+ url: z5.string(),
1269
+ detail: z5.union([z5.literal("auto"), z5.literal("low"), z5.literal("high")]).optional()
313
1270
  }),
314
- type: z.literal("image_url")
1271
+ type: z5.literal("image_url")
315
1272
  });
316
- var ChatCompletionContentPart = z.union([
1273
+ var ChatCompletionContentPart = z5.union([
317
1274
  ChatCompletionContentPartTextWithTitle,
318
1275
  ChatCompletionContentPartImageWithTitle
319
1276
  ]);
320
- var ChatCompletionContentPartText = z.object({
321
- text: z.string().default(""),
322
- type: z.literal("text"),
323
- cache_control: z.object({ type: z.literal("ephemeral") }).optional()
1277
+ var ChatCompletionContentPartText = z5.object({
1278
+ text: z5.string().default(""),
1279
+ type: z5.literal("text"),
1280
+ cache_control: z5.object({ type: z5.literal("ephemeral") }).optional()
324
1281
  });
325
- var ChatCompletionMessageToolCall = z.object({
326
- id: z.string(),
327
- function: z.object({ arguments: z.string(), name: z.string() }),
328
- type: z.literal("function")
1282
+ var ChatCompletionMessageToolCall = z5.object({
1283
+ id: z5.string(),
1284
+ function: z5.object({ arguments: z5.string(), name: z5.string() }),
1285
+ type: z5.literal("function")
329
1286
  });
330
- var ChatCompletionMessageReasoning = z.object({ id: z.string(), content: z.string() }).partial();
331
- var ChatCompletionMessageParam = z.union([
332
- z.object({
333
- content: z.union([z.string(), z.array(ChatCompletionContentPartText)]),
334
- role: z.literal("system"),
335
- name: z.string().optional()
1287
+ var ChatCompletionMessageReasoning = z5.object({ id: z5.string(), content: z5.string() }).partial();
1288
+ var ChatCompletionMessageParam = z5.union([
1289
+ z5.object({
1290
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
1291
+ role: z5.literal("system"),
1292
+ name: z5.string().optional()
336
1293
  }),
337
- z.object({
338
- content: z.union([z.string(), z.array(ChatCompletionContentPart)]),
339
- role: z.literal("user"),
340
- name: z.string().optional()
1294
+ z5.object({
1295
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPart)]),
1296
+ role: z5.literal("user"),
1297
+ name: z5.string().optional()
341
1298
  }),
342
- z.object({
343
- role: z.literal("assistant"),
344
- content: z.union([z.string(), z.array(ChatCompletionContentPartText), z.null()]).optional(),
345
- function_call: z.object({ arguments: z.string(), name: z.string() }).optional(),
346
- name: z.string().optional(),
347
- tool_calls: z.array(ChatCompletionMessageToolCall).optional(),
348
- reasoning: z.array(ChatCompletionMessageReasoning).optional()
1299
+ z5.object({
1300
+ role: z5.literal("assistant"),
1301
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText), z5.null()]).optional(),
1302
+ function_call: z5.object({ arguments: z5.string(), name: z5.string() }).optional(),
1303
+ name: z5.string().optional(),
1304
+ tool_calls: z5.array(ChatCompletionMessageToolCall).optional(),
1305
+ reasoning: z5.array(ChatCompletionMessageReasoning).optional()
349
1306
  }),
350
- z.object({
351
- content: z.union([z.string(), z.array(ChatCompletionContentPartText)]),
352
- role: z.literal("tool"),
353
- tool_call_id: z.string().default("")
1307
+ z5.object({
1308
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
1309
+ role: z5.literal("tool"),
1310
+ tool_call_id: z5.string().default("")
354
1311
  }),
355
- z.object({
356
- content: z.union([z.string(), z.null()]),
357
- name: z.string(),
358
- role: z.literal("function")
1312
+ z5.object({
1313
+ content: z5.union([z5.string(), z5.null()]),
1314
+ name: z5.string(),
1315
+ role: z5.literal("function")
359
1316
  }),
360
- z.object({
361
- content: z.union([z.string(), z.array(ChatCompletionContentPartText)]),
362
- role: z.literal("developer"),
363
- name: z.string().optional()
1317
+ z5.object({
1318
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
1319
+ role: z5.literal("developer"),
1320
+ name: z5.string().optional()
364
1321
  }),
365
- z.object({
366
- role: z.literal("model"),
367
- content: z.union([z.string(), z.null()]).optional()
1322
+ z5.object({
1323
+ role: z5.literal("model"),
1324
+ content: z5.union([z5.string(), z5.null()]).optional()
368
1325
  })
369
1326
  ]);
370
- var ChatCompletionOpenAIMessageParam = z.union([
371
- z.object({
372
- content: z.union([z.string(), z.array(ChatCompletionContentPartText)]),
373
- role: z.literal("system"),
374
- name: z.string().optional()
1327
+ var ChatCompletionOpenAIMessageParam = z5.union([
1328
+ z5.object({
1329
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
1330
+ role: z5.literal("system"),
1331
+ name: z5.string().optional()
375
1332
  }),
376
- z.object({
377
- content: z.union([z.string(), z.array(ChatCompletionContentPart)]),
378
- role: z.literal("user"),
379
- name: z.string().optional()
1333
+ z5.object({
1334
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPart)]),
1335
+ role: z5.literal("user"),
1336
+ name: z5.string().optional()
380
1337
  }),
381
- z.object({
382
- role: z.literal("assistant"),
383
- content: z.union([z.string(), z.array(ChatCompletionContentPartText), z.null()]).optional(),
384
- function_call: z.object({ arguments: z.string(), name: z.string() }).optional(),
385
- name: z.string().optional(),
386
- tool_calls: z.array(ChatCompletionMessageToolCall).optional(),
387
- reasoning: z.array(ChatCompletionMessageReasoning).optional()
1338
+ z5.object({
1339
+ role: z5.literal("assistant"),
1340
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText), z5.null()]).optional(),
1341
+ function_call: z5.object({ arguments: z5.string(), name: z5.string() }).optional(),
1342
+ name: z5.string().optional(),
1343
+ tool_calls: z5.array(ChatCompletionMessageToolCall).optional(),
1344
+ reasoning: z5.array(ChatCompletionMessageReasoning).optional()
388
1345
  }),
389
- z.object({
390
- content: z.union([z.string(), z.array(ChatCompletionContentPartText)]),
391
- role: z.literal("tool"),
392
- tool_call_id: z.string().default("")
1346
+ z5.object({
1347
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
1348
+ role: z5.literal("tool"),
1349
+ tool_call_id: z5.string().default("")
393
1350
  }),
394
- z.object({
395
- content: z.union([z.string(), z.null()]),
396
- name: z.string(),
397
- role: z.literal("function")
1351
+ z5.object({
1352
+ content: z5.union([z5.string(), z5.null()]),
1353
+ name: z5.string(),
1354
+ role: z5.literal("function")
398
1355
  }),
399
- z.object({
400
- content: z.union([z.string(), z.array(ChatCompletionContentPartText)]),
401
- role: z.literal("developer"),
402
- name: z.string().optional()
1356
+ z5.object({
1357
+ content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
1358
+ role: z5.literal("developer"),
1359
+ name: z5.string().optional()
403
1360
  })
404
1361
  ]);
405
- var ChatCompletionTool = z.object({
406
- function: z.object({
407
- name: z.string(),
408
- description: z.string().optional(),
409
- parameters: z.object({}).partial().passthrough().optional()
1362
+ var ChatCompletionTool = z5.object({
1363
+ function: z5.object({
1364
+ name: z5.string(),
1365
+ description: z5.string().optional(),
1366
+ parameters: z5.object({}).partial().passthrough().optional()
410
1367
  }),
411
- type: z.literal("function")
1368
+ type: z5.literal("function")
412
1369
  });
413
- var CodeBundle = z.object({
414
- runtime_context: z.object({
415
- runtime: z.enum(["node", "python"]),
416
- version: z.string()
1370
+ var CodeBundle = z5.object({
1371
+ runtime_context: z5.object({
1372
+ runtime: z5.enum(["node", "python"]),
1373
+ version: z5.string()
417
1374
  }),
418
- location: z.union([
419
- z.object({
420
- type: z.literal("experiment"),
421
- eval_name: z.string(),
422
- position: z.union([
423
- z.object({ type: z.literal("task") }),
424
- z.object({ type: z.literal("scorer"), index: z.number().int().gte(0) })
1375
+ location: z5.union([
1376
+ z5.object({
1377
+ type: z5.literal("experiment"),
1378
+ eval_name: z5.string(),
1379
+ position: z5.union([
1380
+ z5.object({ type: z5.literal("task") }),
1381
+ z5.object({ type: z5.literal("scorer"), index: z5.number().int().gte(0) })
425
1382
  ])
426
1383
  }),
427
- z.object({ type: z.literal("function"), index: z.number().int().gte(0) })
1384
+ z5.object({ type: z5.literal("function"), index: z5.number().int().gte(0) })
428
1385
  ]),
429
- bundle_id: z.string(),
430
- preview: z.union([z.string(), z.null()]).optional()
1386
+ bundle_id: z5.string(),
1387
+ preview: z5.union([z5.string(), z5.null()]).optional()
431
1388
  });
432
- var Dataset = z.object({
433
- id: z.string().uuid(),
434
- project_id: z.string().uuid(),
435
- name: z.string(),
436
- description: z.union([z.string(), z.null()]).optional(),
437
- created: z.union([z.string(), z.null()]).optional(),
438
- deleted_at: z.union([z.string(), z.null()]).optional(),
439
- user_id: z.union([z.string(), z.null()]).optional(),
440
- metadata: z.union([z.object({}).partial().passthrough(), z.null()]).optional()
1389
+ var Dataset = z5.object({
1390
+ id: z5.string().uuid(),
1391
+ project_id: z5.string().uuid(),
1392
+ name: z5.string(),
1393
+ description: z5.union([z5.string(), z5.null()]).optional(),
1394
+ created: z5.union([z5.string(), z5.null()]).optional(),
1395
+ deleted_at: z5.union([z5.string(), z5.null()]).optional(),
1396
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
1397
+ metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
441
1398
  });
442
- var ObjectReferenceNullish = z.union([
443
- z.object({
444
- object_type: z.enum([
1399
+ var ObjectReferenceNullish = z5.union([
1400
+ z5.object({
1401
+ object_type: z5.enum([
445
1402
  "project_logs",
446
1403
  "experiment",
447
1404
  "dataset",
@@ -449,399 +1406,399 @@ var ObjectReferenceNullish = z.union([
449
1406
  "function",
450
1407
  "prompt_session"
451
1408
  ]),
452
- object_id: z.string().uuid(),
453
- id: z.string(),
454
- _xact_id: z.union([z.string(), z.null()]).optional(),
455
- created: z.union([z.string(), z.null()]).optional()
1409
+ object_id: z5.string().uuid(),
1410
+ id: z5.string(),
1411
+ _xact_id: z5.union([z5.string(), z5.null()]).optional(),
1412
+ created: z5.union([z5.string(), z5.null()]).optional()
456
1413
  }),
457
- z.null()
1414
+ z5.null()
458
1415
  ]);
459
- var DatasetEvent = z.object({
460
- id: z.string(),
461
- _xact_id: z.string(),
462
- created: z.string().datetime({ offset: true }),
463
- _pagination_key: z.union([z.string(), z.null()]).optional(),
464
- project_id: z.string().uuid(),
465
- dataset_id: z.string().uuid(),
466
- input: z.unknown().optional(),
467
- expected: z.unknown().optional(),
468
- metadata: z.union([
469
- z.object({ model: z.union([z.string(), z.null()]) }).partial().passthrough(),
470
- z.null()
1416
+ var DatasetEvent = z5.object({
1417
+ id: z5.string(),
1418
+ _xact_id: z5.string(),
1419
+ created: z5.string().datetime({ offset: true }),
1420
+ _pagination_key: z5.union([z5.string(), z5.null()]).optional(),
1421
+ project_id: z5.string().uuid(),
1422
+ dataset_id: z5.string().uuid(),
1423
+ input: z5.unknown().optional(),
1424
+ expected: z5.unknown().optional(),
1425
+ metadata: z5.union([
1426
+ z5.object({ model: z5.union([z5.string(), z5.null()]) }).partial().passthrough(),
1427
+ z5.null()
471
1428
  ]).optional(),
472
- tags: z.union([z.array(z.string()), z.null()]).optional(),
473
- span_id: z.string(),
474
- root_span_id: z.string(),
475
- is_root: z.union([z.boolean(), z.null()]).optional(),
1429
+ tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
1430
+ span_id: z5.string(),
1431
+ root_span_id: z5.string(),
1432
+ is_root: z5.union([z5.boolean(), z5.null()]).optional(),
476
1433
  origin: ObjectReferenceNullish.optional()
477
1434
  });
478
- var EnvVar = z.object({
479
- id: z.string().uuid(),
480
- object_type: z.enum(["organization", "project", "function"]),
481
- object_id: z.string().uuid(),
482
- name: z.string(),
483
- created: z.union([z.string(), z.null()]).optional(),
484
- used: z.union([z.string(), z.null()]).optional()
1435
+ var EnvVar = z5.object({
1436
+ id: z5.string().uuid(),
1437
+ object_type: z5.enum(["organization", "project", "function"]),
1438
+ object_id: z5.string().uuid(),
1439
+ name: z5.string(),
1440
+ created: z5.union([z5.string(), z5.null()]).optional(),
1441
+ used: z5.union([z5.string(), z5.null()]).optional()
485
1442
  });
486
- var RepoInfo = z.union([
487
- z.object({
488
- commit: z.union([z.string(), z.null()]),
489
- branch: z.union([z.string(), z.null()]),
490
- tag: z.union([z.string(), z.null()]),
491
- dirty: z.union([z.boolean(), z.null()]),
492
- author_name: z.union([z.string(), z.null()]),
493
- author_email: z.union([z.string(), z.null()]),
494
- commit_message: z.union([z.string(), z.null()]),
495
- commit_time: z.union([z.string(), z.null()]),
496
- git_diff: z.union([z.string(), z.null()])
1443
+ var RepoInfo = z5.union([
1444
+ z5.object({
1445
+ commit: z5.union([z5.string(), z5.null()]),
1446
+ branch: z5.union([z5.string(), z5.null()]),
1447
+ tag: z5.union([z5.string(), z5.null()]),
1448
+ dirty: z5.union([z5.boolean(), z5.null()]),
1449
+ author_name: z5.union([z5.string(), z5.null()]),
1450
+ author_email: z5.union([z5.string(), z5.null()]),
1451
+ commit_message: z5.union([z5.string(), z5.null()]),
1452
+ commit_time: z5.union([z5.string(), z5.null()]),
1453
+ git_diff: z5.union([z5.string(), z5.null()])
497
1454
  }).partial(),
498
- z.null()
1455
+ z5.null()
499
1456
  ]);
500
- var Experiment = z.object({
501
- id: z.string().uuid(),
502
- project_id: z.string().uuid(),
503
- name: z.string(),
504
- description: z.union([z.string(), z.null()]).optional(),
505
- created: z.union([z.string(), z.null()]).optional(),
1457
+ var Experiment = z5.object({
1458
+ id: z5.string().uuid(),
1459
+ project_id: z5.string().uuid(),
1460
+ name: z5.string(),
1461
+ description: z5.union([z5.string(), z5.null()]).optional(),
1462
+ created: z5.union([z5.string(), z5.null()]).optional(),
506
1463
  repo_info: RepoInfo.optional(),
507
- commit: z.union([z.string(), z.null()]).optional(),
508
- base_exp_id: z.union([z.string(), z.null()]).optional(),
509
- deleted_at: z.union([z.string(), z.null()]).optional(),
510
- dataset_id: z.union([z.string(), z.null()]).optional(),
511
- dataset_version: z.union([z.string(), z.null()]).optional(),
512
- public: z.boolean(),
513
- user_id: z.union([z.string(), z.null()]).optional(),
514
- metadata: z.union([z.object({}).partial().passthrough(), z.null()]).optional(),
515
- tags: z.union([z.array(z.string()), z.null()]).optional()
1464
+ commit: z5.union([z5.string(), z5.null()]).optional(),
1465
+ base_exp_id: z5.union([z5.string(), z5.null()]).optional(),
1466
+ deleted_at: z5.union([z5.string(), z5.null()]).optional(),
1467
+ dataset_id: z5.union([z5.string(), z5.null()]).optional(),
1468
+ dataset_version: z5.union([z5.string(), z5.null()]).optional(),
1469
+ public: z5.boolean(),
1470
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
1471
+ metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
1472
+ tags: z5.union([z5.array(z5.string()), z5.null()]).optional()
516
1473
  });
517
- var SpanType = z.union([
518
- z.enum(["llm", "score", "function", "eval", "task", "tool"]),
519
- z.null()
1474
+ var SpanType = z5.union([
1475
+ z5.enum(["llm", "score", "function", "eval", "task", "tool"]),
1476
+ z5.null()
520
1477
  ]);
521
- var SpanAttributes = z.union([
522
- z.object({ name: z.union([z.string(), z.null()]), type: SpanType }).partial().passthrough(),
523
- z.null()
1478
+ var SpanAttributes = z5.union([
1479
+ z5.object({ name: z5.union([z5.string(), z5.null()]), type: SpanType }).partial().passthrough(),
1480
+ z5.null()
524
1481
  ]);
525
- var ExperimentEvent = z.object({
526
- id: z.string(),
527
- _xact_id: z.string(),
528
- created: z.string().datetime({ offset: true }),
529
- _pagination_key: z.union([z.string(), z.null()]).optional(),
530
- project_id: z.string().uuid(),
531
- experiment_id: z.string().uuid(),
532
- input: z.unknown().optional(),
533
- output: z.unknown().optional(),
534
- expected: z.unknown().optional(),
535
- error: z.unknown().optional(),
536
- scores: z.union([z.record(z.union([z.number(), z.null()])), z.null()]).optional(),
537
- metadata: z.union([
538
- z.object({ model: z.union([z.string(), z.null()]) }).partial().passthrough(),
539
- z.null()
1482
+ var ExperimentEvent = z5.object({
1483
+ id: z5.string(),
1484
+ _xact_id: z5.string(),
1485
+ created: z5.string().datetime({ offset: true }),
1486
+ _pagination_key: z5.union([z5.string(), z5.null()]).optional(),
1487
+ project_id: z5.string().uuid(),
1488
+ experiment_id: z5.string().uuid(),
1489
+ input: z5.unknown().optional(),
1490
+ output: z5.unknown().optional(),
1491
+ expected: z5.unknown().optional(),
1492
+ error: z5.unknown().optional(),
1493
+ scores: z5.union([z5.record(z5.union([z5.number(), z5.null()])), z5.null()]).optional(),
1494
+ metadata: z5.union([
1495
+ z5.object({ model: z5.union([z5.string(), z5.null()]) }).partial().passthrough(),
1496
+ z5.null()
540
1497
  ]).optional(),
541
- tags: z.union([z.array(z.string()), z.null()]).optional(),
542
- metrics: z.union([z.record(z.number()), z.null()]).optional(),
543
- context: z.union([
544
- z.object({
545
- caller_functionname: z.union([z.string(), z.null()]),
546
- caller_filename: z.union([z.string(), z.null()]),
547
- caller_lineno: z.union([z.number(), z.null()])
1498
+ tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
1499
+ metrics: z5.union([z5.record(z5.number()), z5.null()]).optional(),
1500
+ context: z5.union([
1501
+ z5.object({
1502
+ caller_functionname: z5.union([z5.string(), z5.null()]),
1503
+ caller_filename: z5.union([z5.string(), z5.null()]),
1504
+ caller_lineno: z5.union([z5.number(), z5.null()])
548
1505
  }).partial().passthrough(),
549
- z.null()
1506
+ z5.null()
550
1507
  ]).optional(),
551
- span_id: z.string(),
552
- span_parents: z.union([z.array(z.string()), z.null()]).optional(),
553
- root_span_id: z.string(),
1508
+ span_id: z5.string(),
1509
+ span_parents: z5.union([z5.array(z5.string()), z5.null()]).optional(),
1510
+ root_span_id: z5.string(),
554
1511
  span_attributes: SpanAttributes.optional(),
555
- is_root: z.union([z.boolean(), z.null()]).optional(),
1512
+ is_root: z5.union([z5.boolean(), z5.null()]).optional(),
556
1513
  origin: ObjectReferenceNullish.optional()
557
1514
  });
558
- var ExtendedSavedFunctionId = z.union([
559
- z.object({ type: z.literal("function"), id: z.string() }),
560
- z.object({ type: z.literal("global"), name: z.string() }),
561
- z.object({
562
- type: z.literal("slug"),
563
- project_id: z.string(),
564
- slug: z.string()
1515
+ var ExtendedSavedFunctionId = z5.union([
1516
+ z5.object({ type: z5.literal("function"), id: z5.string() }),
1517
+ z5.object({ type: z5.literal("global"), name: z5.string() }),
1518
+ z5.object({
1519
+ type: z5.literal("slug"),
1520
+ project_id: z5.string(),
1521
+ slug: z5.string()
565
1522
  })
566
1523
  ]);
567
- var PromptBlockDataNullish = z.union([
568
- z.object({ type: z.literal("completion"), content: z.string() }),
569
- z.object({
570
- type: z.literal("chat"),
571
- messages: z.array(ChatCompletionMessageParam),
572
- tools: z.string().optional()
1524
+ var PromptBlockDataNullish = z5.union([
1525
+ z5.object({ type: z5.literal("completion"), content: z5.string() }),
1526
+ z5.object({
1527
+ type: z5.literal("chat"),
1528
+ messages: z5.array(ChatCompletionMessageParam),
1529
+ tools: z5.string().optional()
573
1530
  }),
574
- z.null()
1531
+ z5.null()
575
1532
  ]);
576
- var ModelParams = z.union([
577
- z.object({
578
- use_cache: z.boolean(),
579
- temperature: z.number(),
580
- top_p: z.number(),
581
- max_tokens: z.number(),
582
- max_completion_tokens: z.number(),
583
- frequency_penalty: z.number(),
584
- presence_penalty: z.number(),
1533
+ var ModelParams = z5.union([
1534
+ z5.object({
1535
+ use_cache: z5.boolean(),
1536
+ temperature: z5.number(),
1537
+ top_p: z5.number(),
1538
+ max_tokens: z5.number(),
1539
+ max_completion_tokens: z5.number(),
1540
+ frequency_penalty: z5.number(),
1541
+ presence_penalty: z5.number(),
585
1542
  response_format: ResponseFormatNullish,
586
- tool_choice: z.union([
587
- z.literal("auto"),
588
- z.literal("none"),
589
- z.literal("required"),
590
- z.object({
591
- type: z.literal("function"),
592
- function: z.object({ name: z.string() })
1543
+ tool_choice: z5.union([
1544
+ z5.literal("auto"),
1545
+ z5.literal("none"),
1546
+ z5.literal("required"),
1547
+ z5.object({
1548
+ type: z5.literal("function"),
1549
+ function: z5.object({ name: z5.string() })
593
1550
  })
594
1551
  ]),
595
- function_call: z.union([
596
- z.literal("auto"),
597
- z.literal("none"),
598
- z.object({ name: z.string() })
1552
+ function_call: z5.union([
1553
+ z5.literal("auto"),
1554
+ z5.literal("none"),
1555
+ z5.object({ name: z5.string() })
599
1556
  ]),
600
- n: z.number(),
601
- stop: z.array(z.string()),
602
- reasoning_effort: z.enum(["minimal", "low", "medium", "high"]),
603
- verbosity: z.enum(["low", "medium", "high"])
1557
+ n: z5.number(),
1558
+ stop: z5.array(z5.string()),
1559
+ reasoning_effort: z5.enum(["minimal", "low", "medium", "high"]),
1560
+ verbosity: z5.enum(["low", "medium", "high"])
604
1561
  }).partial().passthrough(),
605
- z.object({
606
- use_cache: z.boolean().optional(),
607
- max_tokens: z.number(),
608
- temperature: z.number(),
609
- top_p: z.number().optional(),
610
- top_k: z.number().optional(),
611
- stop_sequences: z.array(z.string()).optional(),
612
- max_tokens_to_sample: z.number().optional()
1562
+ z5.object({
1563
+ use_cache: z5.boolean().optional(),
1564
+ max_tokens: z5.number(),
1565
+ temperature: z5.number(),
1566
+ top_p: z5.number().optional(),
1567
+ top_k: z5.number().optional(),
1568
+ stop_sequences: z5.array(z5.string()).optional(),
1569
+ max_tokens_to_sample: z5.number().optional()
613
1570
  }).passthrough(),
614
- z.object({
615
- use_cache: z.boolean(),
616
- temperature: z.number(),
617
- maxOutputTokens: z.number(),
618
- topP: z.number(),
619
- topK: z.number()
1571
+ z5.object({
1572
+ use_cache: z5.boolean(),
1573
+ temperature: z5.number(),
1574
+ maxOutputTokens: z5.number(),
1575
+ topP: z5.number(),
1576
+ topK: z5.number()
620
1577
  }).partial().passthrough(),
621
- z.object({
622
- use_cache: z.boolean(),
623
- temperature: z.number(),
624
- topK: z.number()
1578
+ z5.object({
1579
+ use_cache: z5.boolean(),
1580
+ temperature: z5.number(),
1581
+ topK: z5.number()
625
1582
  }).partial().passthrough(),
626
- z.object({ use_cache: z.boolean() }).partial().passthrough()
1583
+ z5.object({ use_cache: z5.boolean() }).partial().passthrough()
627
1584
  ]);
628
- var PromptOptionsNullish = z.union([
629
- z.object({ model: z.string(), params: ModelParams, position: z.string() }).partial(),
630
- z.null()
1585
+ var PromptOptionsNullish = z5.union([
1586
+ z5.object({ model: z5.string(), params: ModelParams, position: z5.string() }).partial(),
1587
+ z5.null()
631
1588
  ]);
632
- var PromptParserNullish = z.union([
633
- z.object({
634
- type: z.literal("llm_classifier"),
635
- use_cot: z.boolean(),
636
- choice_scores: z.record(z.number().gte(0).lte(1))
1589
+ var PromptParserNullish = z5.union([
1590
+ z5.object({
1591
+ type: z5.literal("llm_classifier"),
1592
+ use_cot: z5.boolean(),
1593
+ choice_scores: z5.record(z5.number().gte(0).lte(1))
637
1594
  }),
638
- z.null()
1595
+ z5.null()
639
1596
  ]);
640
- var SavedFunctionId = z.union([
641
- z.object({ type: z.literal("function"), id: z.string() }),
642
- z.object({ type: z.literal("global"), name: z.string() })
1597
+ var SavedFunctionId = z5.union([
1598
+ z5.object({ type: z5.literal("function"), id: z5.string() }),
1599
+ z5.object({ type: z5.literal("global"), name: z5.string() })
643
1600
  ]);
644
- var PromptDataNullish = z.union([
645
- z.object({
1601
+ var PromptDataNullish = z5.union([
1602
+ z5.object({
646
1603
  prompt: PromptBlockDataNullish,
647
1604
  options: PromptOptionsNullish,
648
1605
  parser: PromptParserNullish,
649
- tool_functions: z.union([z.array(SavedFunctionId), z.null()]),
650
- origin: z.union([
651
- z.object({
652
- prompt_id: z.string(),
653
- project_id: z.string(),
654
- prompt_version: z.string()
1606
+ tool_functions: z5.union([z5.array(SavedFunctionId), z5.null()]),
1607
+ origin: z5.union([
1608
+ z5.object({
1609
+ prompt_id: z5.string(),
1610
+ project_id: z5.string(),
1611
+ prompt_version: z5.string()
655
1612
  }).partial(),
656
- z.null()
1613
+ z5.null()
657
1614
  ])
658
1615
  }).partial(),
659
- z.null()
1616
+ z5.null()
660
1617
  ]);
661
- var FunctionTypeEnumNullish = z.union([
662
- z.enum(["llm", "scorer", "task", "tool"]),
663
- z.null()
1618
+ var FunctionTypeEnumNullish = z5.union([
1619
+ z5.enum(["llm", "scorer", "task", "tool"]),
1620
+ z5.null()
664
1621
  ]);
665
- var FunctionIdRef = z.object({}).partial().passthrough();
666
- var PromptBlockData = z.union([
667
- z.object({ type: z.literal("completion"), content: z.string() }),
668
- z.object({
669
- type: z.literal("chat"),
670
- messages: z.array(ChatCompletionMessageParam),
671
- tools: z.string().optional()
1622
+ var FunctionIdRef = z5.object({}).partial().passthrough();
1623
+ var PromptBlockData = z5.union([
1624
+ z5.object({ type: z5.literal("completion"), content: z5.string() }),
1625
+ z5.object({
1626
+ type: z5.literal("chat"),
1627
+ messages: z5.array(ChatCompletionMessageParam),
1628
+ tools: z5.string().optional()
672
1629
  })
673
1630
  ]);
674
- var GraphNode = z.union([
675
- z.object({
676
- description: z.union([z.string(), z.null()]).optional(),
677
- position: z.union([z.object({ x: z.number(), y: z.number() }), z.null()]).optional(),
678
- type: z.literal("function"),
1631
+ var GraphNode = z5.union([
1632
+ z5.object({
1633
+ description: z5.union([z5.string(), z5.null()]).optional(),
1634
+ position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
1635
+ type: z5.literal("function"),
679
1636
  function: FunctionIdRef
680
1637
  }),
681
- z.object({
682
- description: z.union([z.string(), z.null()]).optional(),
683
- position: z.union([z.object({ x: z.number(), y: z.number() }), z.null()]).optional(),
684
- type: z.literal("input")
1638
+ z5.object({
1639
+ description: z5.union([z5.string(), z5.null()]).optional(),
1640
+ position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
1641
+ type: z5.literal("input")
685
1642
  }),
686
- z.object({
687
- description: z.union([z.string(), z.null()]).optional(),
688
- position: z.union([z.object({ x: z.number(), y: z.number() }), z.null()]).optional(),
689
- type: z.literal("output")
1643
+ z5.object({
1644
+ description: z5.union([z5.string(), z5.null()]).optional(),
1645
+ position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
1646
+ type: z5.literal("output")
690
1647
  }),
691
- z.object({
692
- description: z.union([z.string(), z.null()]).optional(),
693
- position: z.union([z.object({ x: z.number(), y: z.number() }), z.null()]).optional(),
694
- type: z.literal("literal"),
695
- value: z.unknown().optional()
1648
+ z5.object({
1649
+ description: z5.union([z5.string(), z5.null()]).optional(),
1650
+ position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
1651
+ type: z5.literal("literal"),
1652
+ value: z5.unknown().optional()
696
1653
  }),
697
- z.object({
698
- description: z.union([z.string(), z.null()]).optional(),
699
- position: z.union([z.object({ x: z.number(), y: z.number() }), z.null()]).optional(),
700
- type: z.literal("btql"),
701
- expr: z.string()
1654
+ z5.object({
1655
+ description: z5.union([z5.string(), z5.null()]).optional(),
1656
+ position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
1657
+ type: z5.literal("btql"),
1658
+ expr: z5.string()
702
1659
  }),
703
- z.object({
704
- description: z.union([z.string(), z.null()]).optional(),
705
- position: z.union([z.object({ x: z.number(), y: z.number() }), z.null()]).optional(),
706
- type: z.literal("gate"),
707
- condition: z.union([z.string(), z.null()]).optional()
1660
+ z5.object({
1661
+ description: z5.union([z5.string(), z5.null()]).optional(),
1662
+ position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
1663
+ type: z5.literal("gate"),
1664
+ condition: z5.union([z5.string(), z5.null()]).optional()
708
1665
  }),
709
- z.object({
710
- description: z.union([z.string(), z.null()]).optional(),
711
- position: z.union([z.object({ x: z.number(), y: z.number() }), z.null()]).optional(),
712
- type: z.literal("aggregator")
1666
+ z5.object({
1667
+ description: z5.union([z5.string(), z5.null()]).optional(),
1668
+ position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
1669
+ type: z5.literal("aggregator")
713
1670
  }),
714
- z.object({
715
- description: z.union([z.string(), z.null()]).optional(),
716
- position: z.union([z.object({ x: z.number(), y: z.number() }), z.null()]).optional(),
717
- type: z.literal("prompt_template"),
1671
+ z5.object({
1672
+ description: z5.union([z5.string(), z5.null()]).optional(),
1673
+ position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
1674
+ type: z5.literal("prompt_template"),
718
1675
  prompt: PromptBlockData
719
1676
  })
720
1677
  ]);
721
- var GraphEdge = z.object({
722
- source: z.object({ node: z.string().max(1024), variable: z.string() }),
723
- target: z.object({ node: z.string().max(1024), variable: z.string() }),
724
- purpose: z.enum(["control", "data", "messages"])
1678
+ var GraphEdge = z5.object({
1679
+ source: z5.object({ node: z5.string().max(1024), variable: z5.string() }),
1680
+ target: z5.object({ node: z5.string().max(1024), variable: z5.string() }),
1681
+ purpose: z5.enum(["control", "data", "messages"])
725
1682
  });
726
- var GraphData = z.object({
727
- type: z.literal("graph"),
728
- nodes: z.record(GraphNode),
729
- edges: z.record(GraphEdge)
1683
+ var GraphData = z5.object({
1684
+ type: z5.literal("graph"),
1685
+ nodes: z5.record(GraphNode),
1686
+ edges: z5.record(GraphEdge)
730
1687
  });
731
- var FunctionData = z.union([
732
- z.object({ type: z.literal("prompt") }),
733
- z.object({
734
- type: z.literal("code"),
735
- data: z.union([
736
- z.object({ type: z.literal("bundle") }).and(CodeBundle),
737
- z.object({
738
- type: z.literal("inline"),
739
- runtime_context: z.object({
740
- runtime: z.enum(["node", "python"]),
741
- version: z.string()
1688
+ var FunctionData = z5.union([
1689
+ z5.object({ type: z5.literal("prompt") }),
1690
+ z5.object({
1691
+ type: z5.literal("code"),
1692
+ data: z5.union([
1693
+ z5.object({ type: z5.literal("bundle") }).and(CodeBundle),
1694
+ z5.object({
1695
+ type: z5.literal("inline"),
1696
+ runtime_context: z5.object({
1697
+ runtime: z5.enum(["node", "python"]),
1698
+ version: z5.string()
742
1699
  }),
743
- code: z.string()
1700
+ code: z5.string()
744
1701
  })
745
1702
  ])
746
1703
  }),
747
1704
  GraphData,
748
- z.object({
749
- type: z.literal("remote_eval"),
750
- endpoint: z.string(),
751
- eval_name: z.string(),
752
- parameters: z.object({}).partial().passthrough()
1705
+ z5.object({
1706
+ type: z5.literal("remote_eval"),
1707
+ endpoint: z5.string(),
1708
+ eval_name: z5.string(),
1709
+ parameters: z5.object({}).partial().passthrough()
753
1710
  }),
754
- z.object({ type: z.literal("global"), name: z.string() })
1711
+ z5.object({ type: z5.literal("global"), name: z5.string() })
755
1712
  ]);
756
- var Function = z.object({
757
- id: z.string().uuid(),
758
- _xact_id: z.string(),
759
- project_id: z.string().uuid(),
760
- log_id: z.literal("p"),
761
- org_id: z.string().uuid(),
762
- name: z.string(),
763
- slug: z.string(),
764
- description: z.union([z.string(), z.null()]).optional(),
765
- created: z.union([z.string(), z.null()]).optional(),
1713
+ var Function = z5.object({
1714
+ id: z5.string().uuid(),
1715
+ _xact_id: z5.string(),
1716
+ project_id: z5.string().uuid(),
1717
+ log_id: z5.literal("p"),
1718
+ org_id: z5.string().uuid(),
1719
+ name: z5.string(),
1720
+ slug: z5.string(),
1721
+ description: z5.union([z5.string(), z5.null()]).optional(),
1722
+ created: z5.union([z5.string(), z5.null()]).optional(),
766
1723
  prompt_data: PromptDataNullish.optional(),
767
- tags: z.union([z.array(z.string()), z.null()]).optional(),
768
- metadata: z.union([z.object({}).partial().passthrough(), z.null()]).optional(),
1724
+ tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
1725
+ metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
769
1726
  function_type: FunctionTypeEnumNullish.optional(),
770
1727
  function_data: FunctionData,
771
- origin: z.union([
772
- z.object({
773
- object_type: AclObjectType.and(z.string()),
774
- object_id: z.string().uuid(),
775
- internal: z.union([z.boolean(), z.null()]).optional()
1728
+ origin: z5.union([
1729
+ z5.object({
1730
+ object_type: AclObjectType.and(z5.string()),
1731
+ object_id: z5.string().uuid(),
1732
+ internal: z5.union([z5.boolean(), z5.null()]).optional()
776
1733
  }),
777
- z.null()
1734
+ z5.null()
778
1735
  ]).optional(),
779
- function_schema: z.union([
780
- z.object({ parameters: z.unknown(), returns: z.unknown() }).partial(),
781
- z.null()
1736
+ function_schema: z5.union([
1737
+ z5.object({ parameters: z5.unknown(), returns: z5.unknown() }).partial(),
1738
+ z5.null()
782
1739
  ]).optional()
783
1740
  });
784
- var FunctionFormat = z.enum(["llm", "code", "global", "graph"]);
785
- var PromptData = z.object({
1741
+ var FunctionFormat = z5.enum(["llm", "code", "global", "graph"]);
1742
+ var PromptData = z5.object({
786
1743
  prompt: PromptBlockDataNullish,
787
1744
  options: PromptOptionsNullish,
788
1745
  parser: PromptParserNullish,
789
- tool_functions: z.union([z.array(SavedFunctionId), z.null()]),
790
- origin: z.union([
791
- z.object({
792
- prompt_id: z.string(),
793
- project_id: z.string(),
794
- prompt_version: z.string()
1746
+ tool_functions: z5.union([z5.array(SavedFunctionId), z5.null()]),
1747
+ origin: z5.union([
1748
+ z5.object({
1749
+ prompt_id: z5.string(),
1750
+ project_id: z5.string(),
1751
+ prompt_version: z5.string()
795
1752
  }).partial(),
796
- z.null()
1753
+ z5.null()
797
1754
  ])
798
1755
  }).partial();
799
- var FunctionTypeEnum = z.enum(["llm", "scorer", "task", "tool"]);
800
- var FunctionId = z.union([
801
- z.object({ function_id: z.string(), version: z.string().optional() }),
802
- z.object({
803
- project_name: z.string(),
804
- slug: z.string(),
805
- version: z.string().optional()
1756
+ var FunctionTypeEnum = z5.enum(["llm", "scorer", "task", "tool"]);
1757
+ var FunctionId = z5.union([
1758
+ z5.object({ function_id: z5.string(), version: z5.string().optional() }),
1759
+ z5.object({
1760
+ project_name: z5.string(),
1761
+ slug: z5.string(),
1762
+ version: z5.string().optional()
806
1763
  }),
807
- z.object({ global_function: z.string() }),
808
- z.object({
809
- prompt_session_id: z.string(),
810
- prompt_session_function_id: z.string(),
811
- version: z.string().optional()
1764
+ z5.object({ global_function: z5.string() }),
1765
+ z5.object({
1766
+ prompt_session_id: z5.string(),
1767
+ prompt_session_function_id: z5.string(),
1768
+ version: z5.string().optional()
812
1769
  }),
813
- z.object({
814
- inline_context: z.object({
815
- runtime: z.enum(["node", "python"]),
816
- version: z.string()
1770
+ z5.object({
1771
+ inline_context: z5.object({
1772
+ runtime: z5.enum(["node", "python"]),
1773
+ version: z5.string()
817
1774
  }),
818
- code: z.string(),
819
- name: z.union([z.string(), z.null()]).optional()
1775
+ code: z5.string(),
1776
+ name: z5.union([z5.string(), z5.null()]).optional()
820
1777
  }),
821
- z.object({
1778
+ z5.object({
822
1779
  inline_prompt: PromptData.optional(),
823
- inline_function: z.object({}).partial().passthrough(),
1780
+ inline_function: z5.object({}).partial().passthrough(),
824
1781
  function_type: FunctionTypeEnum.optional(),
825
- name: z.union([z.string(), z.null()]).optional()
1782
+ name: z5.union([z5.string(), z5.null()]).optional()
826
1783
  }),
827
- z.object({
1784
+ z5.object({
828
1785
  inline_prompt: PromptData,
829
1786
  function_type: FunctionTypeEnum.optional(),
830
- name: z.union([z.string(), z.null()]).optional()
1787
+ name: z5.union([z5.string(), z5.null()]).optional()
831
1788
  })
832
1789
  ]);
833
- var FunctionObjectType = z.enum([
1790
+ var FunctionObjectType = z5.enum([
834
1791
  "prompt",
835
1792
  "tool",
836
1793
  "scorer",
837
1794
  "task",
838
1795
  "agent"
839
1796
  ]);
840
- var FunctionOutputType = z.enum(["completion", "score", "any"]);
841
- var GitMetadataSettings = z.object({
842
- collect: z.enum(["all", "none", "some"]),
843
- fields: z.array(
844
- z.enum([
1797
+ var FunctionOutputType = z5.enum(["completion", "score", "any"]);
1798
+ var GitMetadataSettings = z5.object({
1799
+ collect: z5.enum(["all", "none", "some"]),
1800
+ fields: z5.array(
1801
+ z5.enum([
845
1802
  "commit",
846
1803
  "branch",
847
1804
  "tag",
@@ -854,49 +1811,49 @@ var GitMetadataSettings = z.object({
854
1811
  ])
855
1812
  ).optional()
856
1813
  });
857
- var Group = z.object({
858
- id: z.string().uuid(),
859
- org_id: z.string().uuid(),
860
- user_id: z.union([z.string(), z.null()]).optional(),
861
- created: z.union([z.string(), z.null()]).optional(),
862
- name: z.string(),
863
- description: z.union([z.string(), z.null()]).optional(),
864
- deleted_at: z.union([z.string(), z.null()]).optional(),
865
- member_users: z.union([z.array(z.string().uuid()), z.null()]).optional(),
866
- member_groups: z.union([z.array(z.string().uuid()), z.null()]).optional()
1814
+ var Group = z5.object({
1815
+ id: z5.string().uuid(),
1816
+ org_id: z5.string().uuid(),
1817
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
1818
+ created: z5.union([z5.string(), z5.null()]).optional(),
1819
+ name: z5.string(),
1820
+ description: z5.union([z5.string(), z5.null()]).optional(),
1821
+ deleted_at: z5.union([z5.string(), z5.null()]).optional(),
1822
+ member_users: z5.union([z5.array(z5.string().uuid()), z5.null()]).optional(),
1823
+ member_groups: z5.union([z5.array(z5.string().uuid()), z5.null()]).optional()
867
1824
  });
868
- var IfExists = z.enum(["error", "ignore", "replace"]);
869
- var InvokeParent = z.union([
870
- z.object({
871
- object_type: z.enum(["project_logs", "experiment", "playground_logs"]),
872
- object_id: z.string(),
873
- row_ids: z.union([
874
- z.object({
875
- id: z.string(),
876
- span_id: z.string(),
877
- root_span_id: z.string()
1825
+ var IfExists = z5.enum(["error", "ignore", "replace"]);
1826
+ var InvokeParent = z5.union([
1827
+ z5.object({
1828
+ object_type: z5.enum(["project_logs", "experiment", "playground_logs"]),
1829
+ object_id: z5.string(),
1830
+ row_ids: z5.union([
1831
+ z5.object({
1832
+ id: z5.string(),
1833
+ span_id: z5.string(),
1834
+ root_span_id: z5.string()
878
1835
  }),
879
- z.null()
1836
+ z5.null()
880
1837
  ]).optional(),
881
- propagated_event: z.union([z.object({}).partial().passthrough(), z.null()]).optional()
1838
+ propagated_event: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
882
1839
  }),
883
- z.string()
1840
+ z5.string()
884
1841
  ]);
885
- var StreamingMode = z.union([z.enum(["auto", "parallel"]), z.null()]);
1842
+ var StreamingMode = z5.union([z5.enum(["auto", "parallel"]), z5.null()]);
886
1843
  var InvokeFunction = FunctionId.and(
887
- z.object({
888
- input: z.unknown(),
889
- expected: z.unknown(),
890
- metadata: z.union([z.object({}).partial().passthrough(), z.null()]),
891
- tags: z.union([z.array(z.string()), z.null()]),
892
- messages: z.array(ChatCompletionMessageParam),
1844
+ z5.object({
1845
+ input: z5.unknown(),
1846
+ expected: z5.unknown(),
1847
+ metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]),
1848
+ tags: z5.union([z5.array(z5.string()), z5.null()]),
1849
+ messages: z5.array(ChatCompletionMessageParam),
893
1850
  parent: InvokeParent,
894
- stream: z.union([z.boolean(), z.null()]),
1851
+ stream: z5.union([z5.boolean(), z5.null()]),
895
1852
  mode: StreamingMode,
896
- strict: z.union([z.boolean(), z.null()])
1853
+ strict: z5.union([z5.boolean(), z5.null()])
897
1854
  }).partial()
898
1855
  );
899
- var MessageRole = z.enum([
1856
+ var MessageRole = z5.enum([
900
1857
  "system",
901
1858
  "user",
902
1859
  "assistant",
@@ -905,8 +1862,8 @@ var MessageRole = z.enum([
905
1862
  "model",
906
1863
  "developer"
907
1864
  ]);
908
- var ObjectReference = z.object({
909
- object_type: z.enum([
1865
+ var ObjectReference = z5.object({
1866
+ object_type: z5.enum([
910
1867
  "project_logs",
911
1868
  "experiment",
912
1869
  "dataset",
@@ -914,146 +1871,146 @@ var ObjectReference = z.object({
914
1871
  "function",
915
1872
  "prompt_session"
916
1873
  ]),
917
- object_id: z.string().uuid(),
918
- id: z.string(),
919
- _xact_id: z.union([z.string(), z.null()]).optional(),
920
- created: z.union([z.string(), z.null()]).optional()
1874
+ object_id: z5.string().uuid(),
1875
+ id: z5.string(),
1876
+ _xact_id: z5.union([z5.string(), z5.null()]).optional(),
1877
+ created: z5.union([z5.string(), z5.null()]).optional()
921
1878
  });
922
- var OnlineScoreConfig = z.union([
923
- z.object({
924
- sampling_rate: z.number().gte(0).lte(1),
925
- scorers: z.array(SavedFunctionId),
926
- btql_filter: z.union([z.string(), z.null()]).optional(),
927
- apply_to_root_span: z.union([z.boolean(), z.null()]).optional(),
928
- apply_to_span_names: z.union([z.array(z.string()), z.null()]).optional(),
929
- skip_logging: z.union([z.boolean(), z.null()]).optional()
1879
+ var OnlineScoreConfig = z5.union([
1880
+ z5.object({
1881
+ sampling_rate: z5.number().gte(0).lte(1),
1882
+ scorers: z5.array(SavedFunctionId),
1883
+ btql_filter: z5.union([z5.string(), z5.null()]).optional(),
1884
+ apply_to_root_span: z5.union([z5.boolean(), z5.null()]).optional(),
1885
+ apply_to_span_names: z5.union([z5.array(z5.string()), z5.null()]).optional(),
1886
+ skip_logging: z5.union([z5.boolean(), z5.null()]).optional()
930
1887
  }),
931
- z.null()
1888
+ z5.null()
932
1889
  ]);
933
- var Organization = z.object({
934
- id: z.string().uuid(),
935
- name: z.string(),
936
- api_url: z.union([z.string(), z.null()]).optional(),
937
- is_universal_api: z.union([z.boolean(), z.null()]).optional(),
938
- proxy_url: z.union([z.string(), z.null()]).optional(),
939
- realtime_url: z.union([z.string(), z.null()]).optional(),
940
- created: z.union([z.string(), z.null()]).optional()
1890
+ var Organization = z5.object({
1891
+ id: z5.string().uuid(),
1892
+ name: z5.string(),
1893
+ api_url: z5.union([z5.string(), z5.null()]).optional(),
1894
+ is_universal_api: z5.union([z5.boolean(), z5.null()]).optional(),
1895
+ proxy_url: z5.union([z5.string(), z5.null()]).optional(),
1896
+ realtime_url: z5.union([z5.string(), z5.null()]).optional(),
1897
+ created: z5.union([z5.string(), z5.null()]).optional()
941
1898
  });
942
- var ProjectSettings = z.union([
943
- z.object({
944
- comparison_key: z.union([z.string(), z.null()]),
945
- baseline_experiment_id: z.union([z.string(), z.null()]),
946
- spanFieldOrder: z.union([
947
- z.array(
948
- z.object({
949
- object_type: z.string(),
950
- column_id: z.string(),
951
- position: z.string(),
952
- layout: z.union([z.literal("full"), z.literal("two_column"), z.null()]).optional()
1899
+ var ProjectSettings = z5.union([
1900
+ z5.object({
1901
+ comparison_key: z5.union([z5.string(), z5.null()]),
1902
+ baseline_experiment_id: z5.union([z5.string(), z5.null()]),
1903
+ spanFieldOrder: z5.union([
1904
+ z5.array(
1905
+ z5.object({
1906
+ object_type: z5.string(),
1907
+ column_id: z5.string(),
1908
+ position: z5.string(),
1909
+ layout: z5.union([z5.literal("full"), z5.literal("two_column"), z5.null()]).optional()
953
1910
  })
954
1911
  ),
955
- z.null()
1912
+ z5.null()
956
1913
  ]),
957
- remote_eval_sources: z.union([
958
- z.array(
959
- z.object({
960
- url: z.string(),
961
- name: z.string(),
962
- description: z.union([z.string(), z.null()]).optional()
1914
+ remote_eval_sources: z5.union([
1915
+ z5.array(
1916
+ z5.object({
1917
+ url: z5.string(),
1918
+ name: z5.string(),
1919
+ description: z5.union([z5.string(), z5.null()]).optional()
963
1920
  })
964
1921
  ),
965
- z.null()
1922
+ z5.null()
966
1923
  ])
967
1924
  }).partial(),
968
- z.null()
1925
+ z5.null()
969
1926
  ]);
970
- var Project = z.object({
971
- id: z.string().uuid(),
972
- org_id: z.string().uuid(),
973
- name: z.string(),
974
- created: z.union([z.string(), z.null()]).optional(),
975
- deleted_at: z.union([z.string(), z.null()]).optional(),
976
- user_id: z.union([z.string(), z.null()]).optional(),
1927
+ var Project = z5.object({
1928
+ id: z5.string().uuid(),
1929
+ org_id: z5.string().uuid(),
1930
+ name: z5.string(),
1931
+ created: z5.union([z5.string(), z5.null()]).optional(),
1932
+ deleted_at: z5.union([z5.string(), z5.null()]).optional(),
1933
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
977
1934
  settings: ProjectSettings.optional()
978
1935
  });
979
- var RetentionObjectType = z.enum([
1936
+ var RetentionObjectType = z5.enum([
980
1937
  "project_logs",
981
1938
  "experiment",
982
1939
  "dataset"
983
1940
  ]);
984
- var ProjectAutomation = z.object({
985
- id: z.string().uuid(),
986
- project_id: z.string().uuid(),
987
- user_id: z.union([z.string(), z.null()]).optional(),
988
- created: z.union([z.string(), z.null()]).optional(),
989
- name: z.string(),
990
- description: z.union([z.string(), z.null()]).optional(),
991
- config: z.union([
992
- z.object({
993
- event_type: z.literal("logs"),
994
- btql_filter: z.string(),
995
- interval_seconds: z.number().gte(1).lte(2592e3),
996
- action: z.object({ type: z.literal("webhook"), url: z.string() })
1941
+ var ProjectAutomation = z5.object({
1942
+ id: z5.string().uuid(),
1943
+ project_id: z5.string().uuid(),
1944
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
1945
+ created: z5.union([z5.string(), z5.null()]).optional(),
1946
+ name: z5.string(),
1947
+ description: z5.union([z5.string(), z5.null()]).optional(),
1948
+ config: z5.union([
1949
+ z5.object({
1950
+ event_type: z5.literal("logs"),
1951
+ btql_filter: z5.string(),
1952
+ interval_seconds: z5.number().gte(1).lte(2592e3),
1953
+ action: z5.object({ type: z5.literal("webhook"), url: z5.string() })
997
1954
  }),
998
- z.object({
999
- event_type: z.literal("btql_export"),
1000
- export_definition: z.union([
1001
- z.object({ type: z.literal("log_traces") }),
1002
- z.object({ type: z.literal("log_spans") }),
1003
- z.object({ type: z.literal("btql_query"), btql_query: z.string() })
1955
+ z5.object({
1956
+ event_type: z5.literal("btql_export"),
1957
+ export_definition: z5.union([
1958
+ z5.object({ type: z5.literal("log_traces") }),
1959
+ z5.object({ type: z5.literal("log_spans") }),
1960
+ z5.object({ type: z5.literal("btql_query"), btql_query: z5.string() })
1004
1961
  ]),
1005
- export_path: z.string(),
1006
- format: z.enum(["jsonl", "parquet"]),
1007
- interval_seconds: z.number().gte(1).lte(2592e3),
1008
- credentials: z.object({
1009
- type: z.literal("aws_iam"),
1010
- role_arn: z.string(),
1011
- external_id: z.string()
1962
+ export_path: z5.string(),
1963
+ format: z5.enum(["jsonl", "parquet"]),
1964
+ interval_seconds: z5.number().gte(1).lte(2592e3),
1965
+ credentials: z5.object({
1966
+ type: z5.literal("aws_iam"),
1967
+ role_arn: z5.string(),
1968
+ external_id: z5.string()
1012
1969
  }),
1013
- batch_size: z.union([z.number(), z.null()]).optional()
1970
+ batch_size: z5.union([z5.number(), z5.null()]).optional()
1014
1971
  }),
1015
- z.object({
1016
- event_type: z.literal("retention"),
1972
+ z5.object({
1973
+ event_type: z5.literal("retention"),
1017
1974
  object_type: RetentionObjectType,
1018
- retention_days: z.number().gte(0)
1975
+ retention_days: z5.number().gte(0)
1019
1976
  })
1020
1977
  ])
1021
1978
  });
1022
- var ProjectLogsEvent = z.object({
1023
- id: z.string(),
1024
- _xact_id: z.string(),
1025
- _pagination_key: z.union([z.string(), z.null()]).optional(),
1026
- created: z.string().datetime({ offset: true }),
1027
- org_id: z.string().uuid(),
1028
- project_id: z.string().uuid(),
1029
- log_id: z.literal("g"),
1030
- input: z.unknown().optional(),
1031
- output: z.unknown().optional(),
1032
- expected: z.unknown().optional(),
1033
- error: z.unknown().optional(),
1034
- scores: z.union([z.record(z.union([z.number(), z.null()])), z.null()]).optional(),
1035
- metadata: z.union([
1036
- z.object({ model: z.union([z.string(), z.null()]) }).partial().passthrough(),
1037
- z.null()
1979
+ var ProjectLogsEvent = z5.object({
1980
+ id: z5.string(),
1981
+ _xact_id: z5.string(),
1982
+ _pagination_key: z5.union([z5.string(), z5.null()]).optional(),
1983
+ created: z5.string().datetime({ offset: true }),
1984
+ org_id: z5.string().uuid(),
1985
+ project_id: z5.string().uuid(),
1986
+ log_id: z5.literal("g"),
1987
+ input: z5.unknown().optional(),
1988
+ output: z5.unknown().optional(),
1989
+ expected: z5.unknown().optional(),
1990
+ error: z5.unknown().optional(),
1991
+ scores: z5.union([z5.record(z5.union([z5.number(), z5.null()])), z5.null()]).optional(),
1992
+ metadata: z5.union([
1993
+ z5.object({ model: z5.union([z5.string(), z5.null()]) }).partial().passthrough(),
1994
+ z5.null()
1038
1995
  ]).optional(),
1039
- tags: z.union([z.array(z.string()), z.null()]).optional(),
1040
- metrics: z.union([z.record(z.number()), z.null()]).optional(),
1041
- context: z.union([
1042
- z.object({
1043
- caller_functionname: z.union([z.string(), z.null()]),
1044
- caller_filename: z.union([z.string(), z.null()]),
1045
- caller_lineno: z.union([z.number(), z.null()])
1996
+ tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
1997
+ metrics: z5.union([z5.record(z5.number()), z5.null()]).optional(),
1998
+ context: z5.union([
1999
+ z5.object({
2000
+ caller_functionname: z5.union([z5.string(), z5.null()]),
2001
+ caller_filename: z5.union([z5.string(), z5.null()]),
2002
+ caller_lineno: z5.union([z5.number(), z5.null()])
1046
2003
  }).partial().passthrough(),
1047
- z.null()
2004
+ z5.null()
1048
2005
  ]).optional(),
1049
- span_id: z.string(),
1050
- span_parents: z.union([z.array(z.string()), z.null()]).optional(),
1051
- root_span_id: z.string(),
1052
- is_root: z.union([z.boolean(), z.null()]).optional(),
2006
+ span_id: z5.string(),
2007
+ span_parents: z5.union([z5.array(z5.string()), z5.null()]).optional(),
2008
+ root_span_id: z5.string(),
2009
+ is_root: z5.union([z5.boolean(), z5.null()]).optional(),
1053
2010
  span_attributes: SpanAttributes.optional(),
1054
2011
  origin: ObjectReferenceNullish.optional()
1055
2012
  });
1056
- var ProjectScoreType = z.enum([
2013
+ var ProjectScoreType = z5.enum([
1057
2014
  "slider",
1058
2015
  "categorical",
1059
2016
  "weighted",
@@ -1062,172 +2019,172 @@ var ProjectScoreType = z.enum([
1062
2019
  "online",
1063
2020
  "free-form"
1064
2021
  ]);
1065
- var ProjectScoreCategory = z.object({
1066
- name: z.string(),
1067
- value: z.number()
2022
+ var ProjectScoreCategory = z5.object({
2023
+ name: z5.string(),
2024
+ value: z5.number()
1068
2025
  });
1069
- var ProjectScoreCategories = z.union([
1070
- z.array(ProjectScoreCategory),
1071
- z.record(z.number()),
1072
- z.array(z.string()),
1073
- z.null()
2026
+ var ProjectScoreCategories = z5.union([
2027
+ z5.array(ProjectScoreCategory),
2028
+ z5.record(z5.number()),
2029
+ z5.array(z5.string()),
2030
+ z5.null()
1074
2031
  ]);
1075
- var ProjectScoreConfig = z.union([
1076
- z.object({
1077
- multi_select: z.union([z.boolean(), z.null()]),
1078
- destination: z.union([z.string(), z.null()]),
2032
+ var ProjectScoreConfig = z5.union([
2033
+ z5.object({
2034
+ multi_select: z5.union([z5.boolean(), z5.null()]),
2035
+ destination: z5.union([z5.string(), z5.null()]),
1079
2036
  online: OnlineScoreConfig
1080
2037
  }).partial(),
1081
- z.null()
2038
+ z5.null()
1082
2039
  ]);
1083
- var ProjectScore = z.object({
1084
- id: z.string().uuid(),
1085
- project_id: z.string().uuid(),
1086
- user_id: z.string().uuid(),
1087
- created: z.union([z.string(), z.null()]).optional(),
1088
- name: z.string(),
1089
- description: z.union([z.string(), z.null()]).optional(),
2040
+ var ProjectScore = z5.object({
2041
+ id: z5.string().uuid(),
2042
+ project_id: z5.string().uuid(),
2043
+ user_id: z5.string().uuid(),
2044
+ created: z5.union([z5.string(), z5.null()]).optional(),
2045
+ name: z5.string(),
2046
+ description: z5.union([z5.string(), z5.null()]).optional(),
1090
2047
  score_type: ProjectScoreType,
1091
2048
  categories: ProjectScoreCategories.optional(),
1092
2049
  config: ProjectScoreConfig.optional(),
1093
- position: z.union([z.string(), z.null()]).optional()
2050
+ position: z5.union([z5.string(), z5.null()]).optional()
1094
2051
  });
1095
- var ProjectTag = z.object({
1096
- id: z.string().uuid(),
1097
- project_id: z.string().uuid(),
1098
- user_id: z.string().uuid(),
1099
- created: z.union([z.string(), z.null()]).optional(),
1100
- name: z.string(),
1101
- description: z.union([z.string(), z.null()]).optional(),
1102
- color: z.union([z.string(), z.null()]).optional(),
1103
- position: z.union([z.string(), z.null()]).optional()
2052
+ var ProjectTag = z5.object({
2053
+ id: z5.string().uuid(),
2054
+ project_id: z5.string().uuid(),
2055
+ user_id: z5.string().uuid(),
2056
+ created: z5.union([z5.string(), z5.null()]).optional(),
2057
+ name: z5.string(),
2058
+ description: z5.union([z5.string(), z5.null()]).optional(),
2059
+ color: z5.union([z5.string(), z5.null()]).optional(),
2060
+ position: z5.union([z5.string(), z5.null()]).optional()
1104
2061
  });
1105
- var Prompt = z.object({
1106
- id: z.string().uuid(),
1107
- _xact_id: z.string(),
1108
- project_id: z.string().uuid(),
1109
- log_id: z.literal("p"),
1110
- org_id: z.string().uuid(),
1111
- name: z.string(),
1112
- slug: z.string(),
1113
- description: z.union([z.string(), z.null()]).optional(),
1114
- created: z.union([z.string(), z.null()]).optional(),
2062
+ var Prompt = z5.object({
2063
+ id: z5.string().uuid(),
2064
+ _xact_id: z5.string(),
2065
+ project_id: z5.string().uuid(),
2066
+ log_id: z5.literal("p"),
2067
+ org_id: z5.string().uuid(),
2068
+ name: z5.string(),
2069
+ slug: z5.string(),
2070
+ description: z5.union([z5.string(), z5.null()]).optional(),
2071
+ created: z5.union([z5.string(), z5.null()]).optional(),
1115
2072
  prompt_data: PromptDataNullish.optional(),
1116
- tags: z.union([z.array(z.string()), z.null()]).optional(),
1117
- metadata: z.union([z.object({}).partial().passthrough(), z.null()]).optional(),
2073
+ tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
2074
+ metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
1118
2075
  function_type: FunctionTypeEnumNullish.optional()
1119
2076
  });
1120
- var PromptOptions = z.object({ model: z.string(), params: ModelParams, position: z.string() }).partial();
1121
- var PromptSessionEvent = z.object({
1122
- id: z.string(),
1123
- _xact_id: z.string(),
1124
- created: z.string().datetime({ offset: true }),
1125
- _pagination_key: z.union([z.string(), z.null()]).optional(),
1126
- project_id: z.string().uuid(),
1127
- prompt_session_id: z.string().uuid(),
1128
- prompt_session_data: z.unknown().optional(),
1129
- prompt_data: z.unknown().optional(),
1130
- function_data: z.unknown().optional(),
2077
+ var PromptOptions = z5.object({ model: z5.string(), params: ModelParams, position: z5.string() }).partial();
2078
+ var PromptSessionEvent = z5.object({
2079
+ id: z5.string(),
2080
+ _xact_id: z5.string(),
2081
+ created: z5.string().datetime({ offset: true }),
2082
+ _pagination_key: z5.union([z5.string(), z5.null()]).optional(),
2083
+ project_id: z5.string().uuid(),
2084
+ prompt_session_id: z5.string().uuid(),
2085
+ prompt_session_data: z5.unknown().optional(),
2086
+ prompt_data: z5.unknown().optional(),
2087
+ function_data: z5.unknown().optional(),
1131
2088
  function_type: FunctionTypeEnumNullish.optional(),
1132
- object_data: z.unknown().optional(),
1133
- completion: z.unknown().optional(),
1134
- tags: z.union([z.array(z.string()), z.null()]).optional()
2089
+ object_data: z5.unknown().optional(),
2090
+ completion: z5.unknown().optional(),
2091
+ tags: z5.union([z5.array(z5.string()), z5.null()]).optional()
1135
2092
  });
1136
- var ResponseFormat = z.union([
1137
- z.object({ type: z.literal("json_object") }),
1138
- z.object({
1139
- type: z.literal("json_schema"),
2093
+ var ResponseFormat = z5.union([
2094
+ z5.object({ type: z5.literal("json_object") }),
2095
+ z5.object({
2096
+ type: z5.literal("json_schema"),
1140
2097
  json_schema: ResponseFormatJsonSchema
1141
2098
  }),
1142
- z.object({ type: z.literal("text") })
2099
+ z5.object({ type: z5.literal("text") })
1143
2100
  ]);
1144
- var Role = z.object({
1145
- id: z.string().uuid(),
1146
- org_id: z.union([z.string(), z.null()]).optional(),
1147
- user_id: z.union([z.string(), z.null()]).optional(),
1148
- created: z.union([z.string(), z.null()]).optional(),
1149
- name: z.string(),
1150
- description: z.union([z.string(), z.null()]).optional(),
1151
- deleted_at: z.union([z.string(), z.null()]).optional(),
1152
- member_permissions: z.union([
1153
- z.array(
1154
- z.object({
2101
+ var Role = z5.object({
2102
+ id: z5.string().uuid(),
2103
+ org_id: z5.union([z5.string(), z5.null()]).optional(),
2104
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
2105
+ created: z5.union([z5.string(), z5.null()]).optional(),
2106
+ name: z5.string(),
2107
+ description: z5.union([z5.string(), z5.null()]).optional(),
2108
+ deleted_at: z5.union([z5.string(), z5.null()]).optional(),
2109
+ member_permissions: z5.union([
2110
+ z5.array(
2111
+ z5.object({
1155
2112
  permission: Permission,
1156
2113
  restrict_object_type: AclObjectType.optional()
1157
2114
  })
1158
2115
  ),
1159
- z.null()
2116
+ z5.null()
1160
2117
  ]).optional(),
1161
- member_roles: z.union([z.array(z.string().uuid()), z.null()]).optional()
2118
+ member_roles: z5.union([z5.array(z5.string().uuid()), z5.null()]).optional()
1162
2119
  });
1163
- var RunEval = z.object({
1164
- project_id: z.string(),
1165
- data: z.union([
1166
- z.object({
1167
- dataset_id: z.string(),
1168
- _internal_btql: z.union([z.object({}).partial().passthrough(), z.null()]).optional()
2120
+ var RunEval = z5.object({
2121
+ project_id: z5.string(),
2122
+ data: z5.union([
2123
+ z5.object({
2124
+ dataset_id: z5.string(),
2125
+ _internal_btql: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
1169
2126
  }),
1170
- z.object({
1171
- project_name: z.string(),
1172
- dataset_name: z.string(),
1173
- _internal_btql: z.union([z.object({}).partial().passthrough(), z.null()]).optional()
2127
+ z5.object({
2128
+ project_name: z5.string(),
2129
+ dataset_name: z5.string(),
2130
+ _internal_btql: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
1174
2131
  }),
1175
- z.object({ data: z.array(z.unknown()) })
2132
+ z5.object({ data: z5.array(z5.unknown()) })
1176
2133
  ]),
1177
- task: FunctionId.and(z.unknown()),
1178
- scores: z.array(FunctionId),
1179
- experiment_name: z.string().optional(),
1180
- metadata: z.object({}).partial().passthrough().optional(),
1181
- parent: InvokeParent.and(z.unknown()).optional(),
1182
- stream: z.boolean().optional(),
1183
- trial_count: z.union([z.number(), z.null()]).optional(),
1184
- is_public: z.union([z.boolean(), z.null()]).optional(),
1185
- timeout: z.union([z.number(), z.null()]).optional(),
1186
- max_concurrency: z.union([z.number(), z.null()]).optional().default(10),
1187
- base_experiment_name: z.union([z.string(), z.null()]).optional(),
1188
- base_experiment_id: z.union([z.string(), z.null()]).optional(),
2134
+ task: FunctionId.and(z5.unknown()),
2135
+ scores: z5.array(FunctionId),
2136
+ experiment_name: z5.string().optional(),
2137
+ metadata: z5.object({}).partial().passthrough().optional(),
2138
+ parent: InvokeParent.and(z5.unknown()).optional(),
2139
+ stream: z5.boolean().optional(),
2140
+ trial_count: z5.union([z5.number(), z5.null()]).optional(),
2141
+ is_public: z5.union([z5.boolean(), z5.null()]).optional(),
2142
+ timeout: z5.union([z5.number(), z5.null()]).optional(),
2143
+ max_concurrency: z5.union([z5.number(), z5.null()]).optional().default(10),
2144
+ base_experiment_name: z5.union([z5.string(), z5.null()]).optional(),
2145
+ base_experiment_id: z5.union([z5.string(), z5.null()]).optional(),
1189
2146
  git_metadata_settings: GitMetadataSettings.and(
1190
- z.union([z.object({}).partial(), z.null()])
2147
+ z5.union([z5.object({}).partial(), z5.null()])
1191
2148
  ).optional(),
1192
- repo_info: RepoInfo.and(z.unknown()).optional(),
1193
- strict: z.union([z.boolean(), z.null()]).optional(),
1194
- stop_token: z.union([z.string(), z.null()]).optional(),
1195
- extra_messages: z.string().optional(),
1196
- tags: z.array(z.string()).optional()
2149
+ repo_info: RepoInfo.and(z5.unknown()).optional(),
2150
+ strict: z5.union([z5.boolean(), z5.null()]).optional(),
2151
+ stop_token: z5.union([z5.string(), z5.null()]).optional(),
2152
+ extra_messages: z5.string().optional(),
2153
+ tags: z5.array(z5.string()).optional()
1197
2154
  });
1198
- var ServiceToken = z.object({
1199
- id: z.string().uuid(),
1200
- created: z.union([z.string(), z.null()]).optional(),
1201
- name: z.string(),
1202
- preview_name: z.string(),
1203
- service_account_id: z.union([z.string(), z.null()]).optional(),
1204
- service_account_email: z.union([z.string(), z.null()]).optional(),
1205
- service_account_name: z.union([z.string(), z.null()]).optional(),
1206
- org_id: z.union([z.string(), z.null()]).optional()
2155
+ var ServiceToken = z5.object({
2156
+ id: z5.string().uuid(),
2157
+ created: z5.union([z5.string(), z5.null()]).optional(),
2158
+ name: z5.string(),
2159
+ preview_name: z5.string(),
2160
+ service_account_id: z5.union([z5.string(), z5.null()]).optional(),
2161
+ service_account_email: z5.union([z5.string(), z5.null()]).optional(),
2162
+ service_account_name: z5.union([z5.string(), z5.null()]).optional(),
2163
+ org_id: z5.union([z5.string(), z5.null()]).optional()
1207
2164
  });
1208
- var SpanIFrame = z.object({
1209
- id: z.string().uuid(),
1210
- project_id: z.string().uuid(),
1211
- user_id: z.union([z.string(), z.null()]).optional(),
1212
- created: z.union([z.string(), z.null()]).optional(),
1213
- deleted_at: z.union([z.string(), z.null()]).optional(),
1214
- name: z.string(),
1215
- description: z.union([z.string(), z.null()]).optional(),
1216
- url: z.string(),
1217
- post_message: z.union([z.boolean(), z.null()]).optional()
2165
+ var SpanIFrame = z5.object({
2166
+ id: z5.string().uuid(),
2167
+ project_id: z5.string().uuid(),
2168
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
2169
+ created: z5.union([z5.string(), z5.null()]).optional(),
2170
+ deleted_at: z5.union([z5.string(), z5.null()]).optional(),
2171
+ name: z5.string(),
2172
+ description: z5.union([z5.string(), z5.null()]).optional(),
2173
+ url: z5.string(),
2174
+ post_message: z5.union([z5.boolean(), z5.null()]).optional()
1218
2175
  });
1219
- var SSEConsoleEventData = z.object({
1220
- stream: z.enum(["stderr", "stdout"]),
1221
- message: z.string()
2176
+ var SSEConsoleEventData = z5.object({
2177
+ stream: z5.enum(["stderr", "stdout"]),
2178
+ message: z5.string()
1222
2179
  });
1223
- var SSEProgressEventData = z.object({
1224
- id: z.string(),
2180
+ var SSEProgressEventData = z5.object({
2181
+ id: z5.string(),
1225
2182
  object_type: FunctionObjectType,
1226
- origin: ObjectReferenceNullish.and(z.unknown()).optional(),
2183
+ origin: ObjectReferenceNullish.and(z5.unknown()).optional(),
1227
2184
  format: FunctionFormat,
1228
2185
  output_type: FunctionOutputType,
1229
- name: z.string(),
1230
- event: z.enum([
2186
+ name: z5.string(),
2187
+ event: z5.enum([
1231
2188
  "reasoning_delta",
1232
2189
  "text_delta",
1233
2190
  "json_delta",
@@ -1237,110 +2194,110 @@ var SSEProgressEventData = z.object({
1237
2194
  "done",
1238
2195
  "progress"
1239
2196
  ]),
1240
- data: z.string()
2197
+ data: z5.string()
1241
2198
  });
1242
- var ToolFunctionDefinition = z.object({
1243
- type: z.literal("function"),
1244
- function: z.object({
1245
- name: z.string(),
1246
- description: z.string().optional(),
1247
- parameters: z.object({}).partial().passthrough().optional(),
1248
- strict: z.union([z.boolean(), z.null()]).optional()
2199
+ var ToolFunctionDefinition = z5.object({
2200
+ type: z5.literal("function"),
2201
+ function: z5.object({
2202
+ name: z5.string(),
2203
+ description: z5.string().optional(),
2204
+ parameters: z5.object({}).partial().passthrough().optional(),
2205
+ strict: z5.union([z5.boolean(), z5.null()]).optional()
1249
2206
  })
1250
2207
  });
1251
- var User = z.object({
1252
- id: z.string().uuid(),
1253
- given_name: z.union([z.string(), z.null()]).optional(),
1254
- family_name: z.union([z.string(), z.null()]).optional(),
1255
- email: z.union([z.string(), z.null()]).optional(),
1256
- avatar_url: z.union([z.string(), z.null()]).optional(),
1257
- created: z.union([z.string(), z.null()]).optional()
2208
+ var User = z5.object({
2209
+ id: z5.string().uuid(),
2210
+ given_name: z5.union([z5.string(), z5.null()]).optional(),
2211
+ family_name: z5.union([z5.string(), z5.null()]).optional(),
2212
+ email: z5.union([z5.string(), z5.null()]).optional(),
2213
+ avatar_url: z5.union([z5.string(), z5.null()]).optional(),
2214
+ created: z5.union([z5.string(), z5.null()]).optional()
1258
2215
  });
1259
- var ViewDataSearch = z.union([
1260
- z.object({
1261
- filter: z.union([z.array(z.unknown()), z.null()]),
1262
- tag: z.union([z.array(z.unknown()), z.null()]),
1263
- match: z.union([z.array(z.unknown()), z.null()]),
1264
- sort: z.union([z.array(z.unknown()), z.null()])
2216
+ var ViewDataSearch = z5.union([
2217
+ z5.object({
2218
+ filter: z5.union([z5.array(z5.unknown()), z5.null()]),
2219
+ tag: z5.union([z5.array(z5.unknown()), z5.null()]),
2220
+ match: z5.union([z5.array(z5.unknown()), z5.null()]),
2221
+ sort: z5.union([z5.array(z5.unknown()), z5.null()])
1265
2222
  }).partial(),
1266
- z.null()
2223
+ z5.null()
1267
2224
  ]);
1268
- var ViewData = z.union([
1269
- z.object({ search: ViewDataSearch }).partial(),
1270
- z.null()
2225
+ var ViewData = z5.union([
2226
+ z5.object({ search: ViewDataSearch }).partial(),
2227
+ z5.null()
1271
2228
  ]);
1272
- var ViewOptions = z.union([
1273
- z.object({
1274
- viewType: z.literal("monitor"),
1275
- options: z.object({
1276
- spanType: z.union([z.enum(["range", "frame"]), z.null()]),
1277
- rangeValue: z.union([z.string(), z.null()]),
1278
- frameStart: z.union([z.string(), z.null()]),
1279
- frameEnd: z.union([z.string(), z.null()]),
1280
- tzUTC: z.union([z.boolean(), z.null()]),
1281
- chartVisibility: z.union([z.record(z.boolean()), z.null()]),
1282
- projectId: z.union([z.string(), z.null()]),
1283
- type: z.union([z.enum(["project", "experiment"]), z.null()]),
1284
- groupBy: z.union([z.string(), z.null()])
2229
+ var ViewOptions = z5.union([
2230
+ z5.object({
2231
+ viewType: z5.literal("monitor"),
2232
+ options: z5.object({
2233
+ spanType: z5.union([z5.enum(["range", "frame"]), z5.null()]),
2234
+ rangeValue: z5.union([z5.string(), z5.null()]),
2235
+ frameStart: z5.union([z5.string(), z5.null()]),
2236
+ frameEnd: z5.union([z5.string(), z5.null()]),
2237
+ tzUTC: z5.union([z5.boolean(), z5.null()]),
2238
+ chartVisibility: z5.union([z5.record(z5.boolean()), z5.null()]),
2239
+ projectId: z5.union([z5.string(), z5.null()]),
2240
+ type: z5.union([z5.enum(["project", "experiment"]), z5.null()]),
2241
+ groupBy: z5.union([z5.string(), z5.null()])
1285
2242
  }).partial()
1286
2243
  }),
1287
- z.object({
1288
- columnVisibility: z.union([z.record(z.boolean()), z.null()]),
1289
- columnOrder: z.union([z.array(z.string()), z.null()]),
1290
- columnSizing: z.union([z.record(z.number()), z.null()]),
1291
- grouping: z.union([z.string(), z.null()]),
1292
- rowHeight: z.union([z.string(), z.null()]),
1293
- tallGroupRows: z.union([z.boolean(), z.null()]),
1294
- layout: z.union([z.string(), z.null()]),
1295
- chartHeight: z.union([z.number(), z.null()]),
1296
- excludedMeasures: z.union([
1297
- z.array(
1298
- z.object({
1299
- type: z.enum(["none", "score", "metric", "metadata"]),
1300
- value: z.string()
2244
+ z5.object({
2245
+ columnVisibility: z5.union([z5.record(z5.boolean()), z5.null()]),
2246
+ columnOrder: z5.union([z5.array(z5.string()), z5.null()]),
2247
+ columnSizing: z5.union([z5.record(z5.number()), z5.null()]),
2248
+ grouping: z5.union([z5.string(), z5.null()]),
2249
+ rowHeight: z5.union([z5.string(), z5.null()]),
2250
+ tallGroupRows: z5.union([z5.boolean(), z5.null()]),
2251
+ layout: z5.union([z5.string(), z5.null()]),
2252
+ chartHeight: z5.union([z5.number(), z5.null()]),
2253
+ excludedMeasures: z5.union([
2254
+ z5.array(
2255
+ z5.object({
2256
+ type: z5.enum(["none", "score", "metric", "metadata"]),
2257
+ value: z5.string()
1301
2258
  })
1302
2259
  ),
1303
- z.null()
2260
+ z5.null()
1304
2261
  ]),
1305
- yMetric: z.union([
1306
- z.object({
1307
- type: z.enum(["none", "score", "metric", "metadata"]),
1308
- value: z.string()
2262
+ yMetric: z5.union([
2263
+ z5.object({
2264
+ type: z5.enum(["none", "score", "metric", "metadata"]),
2265
+ value: z5.string()
1309
2266
  }),
1310
- z.null()
2267
+ z5.null()
1311
2268
  ]),
1312
- xAxis: z.union([
1313
- z.object({
1314
- type: z.enum(["none", "score", "metric", "metadata"]),
1315
- value: z.string()
2269
+ xAxis: z5.union([
2270
+ z5.object({
2271
+ type: z5.enum(["none", "score", "metric", "metadata"]),
2272
+ value: z5.string()
1316
2273
  }),
1317
- z.null()
2274
+ z5.null()
1318
2275
  ]),
1319
- symbolGrouping: z.union([
1320
- z.object({
1321
- type: z.enum(["none", "score", "metric", "metadata"]),
1322
- value: z.string()
2276
+ symbolGrouping: z5.union([
2277
+ z5.object({
2278
+ type: z5.enum(["none", "score", "metric", "metadata"]),
2279
+ value: z5.string()
1323
2280
  }),
1324
- z.null()
2281
+ z5.null()
1325
2282
  ]),
1326
- xAxisAggregation: z.union([z.string(), z.null()]),
1327
- chartAnnotations: z.union([
1328
- z.array(z.object({ id: z.string(), text: z.string() })),
1329
- z.null()
2283
+ xAxisAggregation: z5.union([z5.string(), z5.null()]),
2284
+ chartAnnotations: z5.union([
2285
+ z5.array(z5.object({ id: z5.string(), text: z5.string() })),
2286
+ z5.null()
1330
2287
  ]),
1331
- timeRangeFilter: z.union([
1332
- z.string(),
1333
- z.object({ from: z.string(), to: z.string() }),
1334
- z.null()
2288
+ timeRangeFilter: z5.union([
2289
+ z5.string(),
2290
+ z5.object({ from: z5.string(), to: z5.string() }),
2291
+ z5.null()
1335
2292
  ])
1336
2293
  }).partial(),
1337
- z.null()
2294
+ z5.null()
1338
2295
  ]);
1339
- var View = z.object({
1340
- id: z.string().uuid(),
1341
- object_type: AclObjectType.and(z.string()),
1342
- object_id: z.string().uuid(),
1343
- view_type: z.enum([
2296
+ var View = z5.object({
2297
+ id: z5.string().uuid(),
2298
+ object_type: AclObjectType.and(z5.string()),
2299
+ object_id: z5.string().uuid(),
2300
+ view_type: z5.enum([
1344
2301
  "projects",
1345
2302
  "experiments",
1346
2303
  "experiment",
@@ -1355,56 +2312,56 @@ var View = z.object({
1355
2312
  "agents",
1356
2313
  "monitor"
1357
2314
  ]),
1358
- name: z.string(),
1359
- created: z.union([z.string(), z.null()]).optional(),
2315
+ name: z5.string(),
2316
+ created: z5.union([z5.string(), z5.null()]).optional(),
1360
2317
  view_data: ViewData.optional(),
1361
2318
  options: ViewOptions.optional(),
1362
- user_id: z.union([z.string(), z.null()]).optional(),
1363
- deleted_at: z.union([z.string(), z.null()]).optional()
2319
+ user_id: z5.union([z5.string(), z5.null()]).optional(),
2320
+ deleted_at: z5.union([z5.string(), z5.null()]).optional()
1364
2321
  });
1365
2322
 
1366
2323
  // src/logger.ts
1367
2324
  import { waitUntil } from "@vercel/functions";
1368
2325
  import Mustache2 from "mustache";
1369
- import { z as z3, ZodError } from "zod";
2326
+ import { z as z7, ZodError } from "zod";
1370
2327
 
1371
2328
  // src/functions/stream.ts
1372
2329
  import {
1373
2330
  createParser
1374
2331
  } from "eventsource-parser";
1375
- import { z as z2 } from "zod";
1376
- var braintrustStreamChunkSchema = z2.union([
1377
- z2.object({
1378
- type: z2.literal("text_delta"),
1379
- data: z2.string()
2332
+ import { z as z6 } from "zod/v3";
2333
+ var braintrustStreamChunkSchema = z6.union([
2334
+ z6.object({
2335
+ type: z6.literal("text_delta"),
2336
+ data: z6.string()
1380
2337
  }),
1381
- z2.object({
1382
- type: z2.literal("reasoning_delta"),
1383
- data: z2.string()
2338
+ z6.object({
2339
+ type: z6.literal("reasoning_delta"),
2340
+ data: z6.string()
1384
2341
  }),
1385
- z2.object({
1386
- type: z2.literal("json_delta"),
1387
- data: z2.string()
2342
+ z6.object({
2343
+ type: z6.literal("json_delta"),
2344
+ data: z6.string()
1388
2345
  }),
1389
- z2.object({
1390
- type: z2.literal("error"),
1391
- data: z2.string()
2346
+ z6.object({
2347
+ type: z6.literal("error"),
2348
+ data: z6.string()
1392
2349
  }),
1393
- z2.object({
1394
- type: z2.literal("console"),
2350
+ z6.object({
2351
+ type: z6.literal("console"),
1395
2352
  data: SSEConsoleEventData
1396
2353
  }),
1397
- z2.object({
1398
- type: z2.literal("progress"),
2354
+ z6.object({
2355
+ type: z6.literal("progress"),
1399
2356
  data: SSEProgressEventData
1400
2357
  }),
1401
- z2.object({
1402
- type: z2.literal("start"),
1403
- data: z2.string()
2358
+ z6.object({
2359
+ type: z6.literal("start"),
2360
+ data: z6.string()
1404
2361
  }),
1405
- z2.object({
1406
- type: z2.literal("done"),
1407
- data: z2.string()
2362
+ z6.object({
2363
+ type: z6.literal("done"),
2364
+ data: z6.string()
1408
2365
  })
1409
2366
  ]);
1410
2367
  var BraintrustStream = class _BraintrustStream {
@@ -1995,7 +2952,6 @@ function objectIsEmpty(obj) {
1995
2952
  }
1996
2953
 
1997
2954
  // src/mustache-utils.ts
1998
- import { getObjValueByPath } from "@braintrust/core";
1999
2955
  import Mustache from "mustache";
2000
2956
  function lintTemplate(template, context) {
2001
2957
  const variables = getMustacheVars(template);
@@ -2018,7 +2974,6 @@ function getMustacheVars(prompt) {
2018
2974
  }
2019
2975
 
2020
2976
  // src/logger.ts
2021
- import { prettifyXact } from "@braintrust/core";
2022
2977
  var BRAINTRUST_ATTACHMENT = BraintrustAttachmentReference.shape.type.value;
2023
2978
  var EXTERNAL_ATTACHMENT = ExternalAttachmentReference.shape.type.value;
2024
2979
  var BRAINTRUST_PARAMS = Object.keys(BraintrustModelParams.shape);
@@ -2106,14 +3061,14 @@ var NoopSpan = class {
2106
3061
  };
2107
3062
  var NOOP_SPAN = new NoopSpan();
2108
3063
  var NOOP_SPAN_PERMALINK = "https://braintrust.dev/noop-span";
2109
- var loginSchema = z3.strictObject({
2110
- appUrl: z3.string(),
2111
- appPublicUrl: z3.string(),
2112
- orgName: z3.string(),
2113
- apiUrl: z3.string(),
2114
- proxyUrl: z3.string(),
2115
- loginToken: z3.string(),
2116
- orgId: z3.string().nullish(),
3064
+ var loginSchema = z7.strictObject({
3065
+ appUrl: z7.string(),
3066
+ appPublicUrl: z7.string(),
3067
+ orgName: z7.string(),
3068
+ apiUrl: z7.string(),
3069
+ proxyUrl: z7.string(),
3070
+ loginToken: z7.string(),
3071
+ orgId: z7.string().nullish(),
2117
3072
  gitMetadataSettings: GitMetadataSettings.nullish()
2118
3073
  });
2119
3074
  var stateNonce = 0;
@@ -2590,9 +3545,9 @@ var Attachment = class extends BaseAttachment {
2590
3545
  let signedUrl;
2591
3546
  let headers;
2592
3547
  try {
2593
- ({ signedUrl, headers } = z3.object({
2594
- signedUrl: z3.string().url(),
2595
- headers: z3.record(z3.string())
3548
+ ({ signedUrl, headers } = z7.object({
3549
+ signedUrl: z7.string().url(),
3550
+ headers: z7.record(z7.string())
2596
3551
  }).parse(await metadataResponse.json()));
2597
3552
  } catch (error) {
2598
3553
  if (error instanceof ZodError) {
@@ -2747,8 +3702,8 @@ var ExternalAttachment = class extends BaseAttachment {
2747
3702
  });
2748
3703
  }
2749
3704
  };
2750
- var attachmentMetadataSchema = z3.object({
2751
- downloadUrl: z3.string(),
3705
+ var attachmentMetadataSchema = z7.object({
3706
+ downloadUrl: z7.string(),
2752
3707
  status: AttachmentStatus
2753
3708
  });
2754
3709
  var ReadonlyAttachment = class {
@@ -2960,15 +3915,15 @@ function spanComponentsToObjectIdLambda(state, components) {
2960
3915
  );
2961
3916
  }
2962
3917
  switch (components.data.object_type) {
2963
- case SpanObjectTypeV3.EXPERIMENT:
3918
+ case 1 /* EXPERIMENT */:
2964
3919
  throw new Error(
2965
3920
  "Impossible: computeObjectMetadataArgs not supported for experiments"
2966
3921
  );
2967
- case SpanObjectTypeV3.PLAYGROUND_LOGS:
3922
+ case 3 /* PLAYGROUND_LOGS */:
2968
3923
  throw new Error(
2969
3924
  "Impossible: computeObjectMetadataArgs not supported for prompt sessions"
2970
3925
  );
2971
- case SpanObjectTypeV3.PROJECT_LOGS:
3926
+ case 2 /* PROJECT_LOGS */:
2972
3927
  return async () => (await computeLoggerMetadata(state, {
2973
3928
  ...components.data.compute_object_metadata_args
2974
3929
  })).project.id;
@@ -3120,7 +4075,7 @@ var Logger = class {
3120
4075
  return (async () => (await this.project).id)();
3121
4076
  }
3122
4077
  parentObjectType() {
3123
- return SpanObjectTypeV3.PROJECT_LOGS;
4078
+ return 2 /* PROJECT_LOGS */;
3124
4079
  }
3125
4080
  /**
3126
4081
  * Log a single event. The event will be batched and uploaded behind the scenes if `logOptions.asyncFlush` is true.
@@ -3214,7 +4169,7 @@ var Logger = class {
3214
4169
  parentSpanIds: args?.parentSpanIds,
3215
4170
  propagatedEvent: args?.propagatedEvent
3216
4171
  }),
3217
- defaultRootType: SpanTypeAttribute.TASK
4172
+ defaultRootType: "task" /* TASK */
3218
4173
  });
3219
4174
  }
3220
4175
  /**
@@ -4332,6 +5287,8 @@ function getSpanParentObject(options) {
4332
5287
  if (!Object.is(parentSpan, NOOP_SPAN)) {
4333
5288
  return parentSpan;
4334
5289
  }
5290
+ const parentStr = options?.parent ?? state.currentParent.getStore();
5291
+ if (parentStr) return SpanComponentsV3.fromStr(parentStr);
4335
5292
  const experiment = currentExperiment();
4336
5293
  if (experiment) {
4337
5294
  return experiment;
@@ -4548,35 +5505,35 @@ function setFetch(fetch2) {
4548
5505
  }
4549
5506
  function startSpanAndIsLogger(args) {
4550
5507
  const state = args?.state ?? _globalState;
4551
- const parentStr = args?.parent ?? state.currentParent.getStore();
4552
- const components = parentStr ? SpanComponentsV3.fromStr(parentStr) : void 0;
4553
- if (components) {
4554
- const parentSpanIds = components.data.row_id ? {
4555
- spanId: components.data.span_id,
4556
- rootSpanId: components.data.root_span_id
5508
+ const parentObject = getSpanParentObject({
5509
+ asyncFlush: args?.asyncFlush,
5510
+ parent: args?.parent,
5511
+ state
5512
+ });
5513
+ if (parentObject instanceof SpanComponentsV3) {
5514
+ const parentSpanIds = parentObject.data.row_id ? {
5515
+ spanId: parentObject.data.span_id,
5516
+ rootSpanId: parentObject.data.root_span_id
4557
5517
  } : void 0;
4558
5518
  const span = new SpanImpl({
4559
5519
  state,
4560
5520
  ...args,
4561
- parentObjectType: components.data.object_type,
5521
+ parentObjectType: parentObject.data.object_type,
4562
5522
  parentObjectId: new LazyValue(
4563
- spanComponentsToObjectIdLambda(state, components)
5523
+ spanComponentsToObjectIdLambda(state, parentObject)
4564
5524
  ),
4565
- parentComputeObjectMetadataArgs: components.data.compute_object_metadata_args ?? void 0,
5525
+ parentComputeObjectMetadataArgs: parentObject.data.compute_object_metadata_args ?? void 0,
4566
5526
  parentSpanIds,
4567
5527
  propagatedEvent: args?.propagatedEvent ?? // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
4568
- (components.data.propagated_event ?? void 0)
5528
+ (parentObject.data.propagated_event ?? void 0)
4569
5529
  });
4570
5530
  return {
4571
5531
  span,
4572
- isSyncFlushLogger: components.data.object_type === SpanObjectTypeV3.PROJECT_LOGS && // Since there's no parent logger here, we're free to choose the async flush
5532
+ isSyncFlushLogger: parentObject.data.object_type === 2 /* PROJECT_LOGS */ && // Since there's no parent logger here, we're free to choose the async flush
4573
5533
  // behavior, and therefore propagate along whatever we get from the arguments
4574
5534
  args?.asyncFlush === false
4575
5535
  };
4576
5536
  } else {
4577
- const parentObject = getSpanParentObject({
4578
- asyncFlush: args?.asyncFlush
4579
- });
4580
5537
  const span = parentObject.startSpan(args);
4581
5538
  return {
4582
5539
  span,
@@ -4726,7 +5683,7 @@ function validateAndSanitizeExperimentLogPartialArgs(event) {
4726
5683
  function deepCopyEvent(event) {
4727
5684
  const attachments = [];
4728
5685
  const IDENTIFIER = "_bt_internal_saved_attachment";
4729
- const savedAttachmentSchema = z3.strictObject({ [IDENTIFIER]: z3.number() });
5686
+ const savedAttachmentSchema = z7.strictObject({ [IDENTIFIER]: z7.number() });
4730
5687
  const serialized = JSON.stringify(event, (_k, v) => {
4731
5688
  if (v instanceof SpanImpl || v instanceof NoopSpan) {
4732
5689
  return `<span>`;
@@ -4961,7 +5918,7 @@ var Experiment2 = class extends ObjectFetcher {
4961
5918
  })();
4962
5919
  }
4963
5920
  parentObjectType() {
4964
- return SpanObjectTypeV3.EXPERIMENT;
5921
+ return 1 /* EXPERIMENT */;
4965
5922
  }
4966
5923
  async getState() {
4967
5924
  await this.lazyMetadata.get();
@@ -5045,7 +6002,7 @@ var Experiment2 = class extends ObjectFetcher {
5045
6002
  parentSpanIds: void 0,
5046
6003
  propagatedEvent: args?.propagatedEvent
5047
6004
  }),
5048
- defaultRootType: SpanTypeAttribute.EVAL
6005
+ defaultRootType: "eval" /* EVAL */
5049
6006
  });
5050
6007
  }
5051
6008
  async fetchBaseExperiment() {
@@ -5464,7 +6421,7 @@ var SpanImpl = class _SpanImpl {
5464
6421
  const baseUrl = `${appUrl}/app/${orgName}`;
5465
6422
  const args = this.parentComputeObjectMetadataArgs;
5466
6423
  switch (this.parentObjectType) {
5467
- case SpanObjectTypeV3.PROJECT_LOGS: {
6424
+ case 2 /* PROJECT_LOGS */: {
5468
6425
  const projectID = args?.project_id || this.parentObjectId.getSync().value;
5469
6426
  const projectName = args?.project_name;
5470
6427
  if (projectID) {
@@ -5475,7 +6432,7 @@ var SpanImpl = class _SpanImpl {
5475
6432
  return getErrPermlink("provide-project-name-or-id");
5476
6433
  }
5477
6434
  }
5478
- case SpanObjectTypeV3.EXPERIMENT: {
6435
+ case 1 /* EXPERIMENT */: {
5479
6436
  const expID = args?.experiment_id || this.parentObjectId?.getSync()?.value;
5480
6437
  if (!expID) {
5481
6438
  return getErrPermlink("provide-experiment-id");
@@ -5483,7 +6440,7 @@ var SpanImpl = class _SpanImpl {
5483
6440
  return `${baseUrl}/object?object_type=experiment&object_id=${expID}&id=${this._id}`;
5484
6441
  }
5485
6442
  }
5486
- case SpanObjectTypeV3.PLAYGROUND_LOGS: {
6443
+ case 3 /* PLAYGROUND_LOGS */: {
5487
6444
  return NOOP_SPAN_PERMALINK;
5488
6445
  }
5489
6446
  default: {
@@ -5731,8 +6688,8 @@ var Dataset2 = class extends ObjectFetcher {
5731
6688
  )}`;
5732
6689
  let dataSummary;
5733
6690
  if (summarizeData) {
5734
- const rawDataSummary = z3.object({
5735
- total_records: z3.number()
6691
+ const rawDataSummary = z7.object({
6692
+ total_records: z7.number()
5736
6693
  }).parse(
5737
6694
  await state.apiConn().get_json(
5738
6695
  "dataset-summary",
@@ -5855,11 +6812,11 @@ function renderTemplatedObject(obj, args, options) {
5855
6812
  return obj;
5856
6813
  }
5857
6814
  function renderPromptParams(params, args, options) {
5858
- const schemaParsed = z3.object({
5859
- response_format: z3.object({
5860
- type: z3.literal("json_schema"),
6815
+ const schemaParsed = z7.object({
6816
+ response_format: z7.object({
6817
+ type: z7.literal("json_schema"),
5861
6818
  json_schema: ResponseFormatJsonSchema.omit({ schema: true }).extend({
5862
- schema: z3.unknown()
6819
+ schema: z7.unknown()
5863
6820
  })
5864
6821
  })
5865
6822
  }).safeParse(params);
@@ -5977,7 +6934,7 @@ var Prompt2 = class _Prompt {
5977
6934
  if (!prompt) {
5978
6935
  throw new Error("Empty prompt");
5979
6936
  }
5980
- const dictArgParsed = z3.record(z3.unknown()).safeParse(buildArgs);
6937
+ const dictArgParsed = z7.record(z7.unknown()).safeParse(buildArgs);
5981
6938
  const variables = {
5982
6939
  input: buildArgs,
5983
6940
  ...dictArgParsed.success ? dictArgParsed.data : {}
@@ -6032,7 +6989,7 @@ var Prompt2 = class _Prompt {
6032
6989
  return JSON.stringify(v);
6033
6990
  }
6034
6991
  };
6035
- const dictArgParsed = z3.record(z3.unknown()).safeParse(buildArgs);
6992
+ const dictArgParsed = z7.record(z7.unknown()).safeParse(buildArgs);
6036
6993
  const variables = {
6037
6994
  input: buildArgs,
6038
6995
  ...dictArgParsed.success ? dictArgParsed.data : {}
@@ -6380,12 +7337,7 @@ function initFunction({
6380
7337
  return f;
6381
7338
  }
6382
7339
 
6383
- // src/wrappers/oai.ts
6384
- import { SpanTypeAttribute as SpanTypeAttribute2 } from "@braintrust/core";
6385
- import { mergeDicts as mergeDicts2 } from "@braintrust/core";
6386
-
6387
7340
  // src/wrappers/oai_responses.ts
6388
- import { isObject as isObject2 } from "@braintrust/core";
6389
7341
  function responsesProxy(openai) {
6390
7342
  if (!openai.responses) {
6391
7343
  return openai;
@@ -6583,7 +7535,7 @@ function parseMetricsFromUsage(usage) {
6583
7535
  const metricName = TOKEN_NAME_MAP[oai_name] || oai_name;
6584
7536
  metrics[metricName] = value;
6585
7537
  } else if (oai_name.endsWith("_tokens_details")) {
6586
- if (!isObject2(value)) {
7538
+ if (!isObject(value)) {
6587
7539
  continue;
6588
7540
  }
6589
7541
  const rawPrefix = oai_name.slice(0, -"_tokens_details".length);
@@ -6765,11 +7717,11 @@ function wrapBetaChatCompletionParse(completion) {
6765
7717
  return async (allParams) => {
6766
7718
  const { span_info: _, ...params } = allParams;
6767
7719
  const span = startSpan(
6768
- mergeDicts2(
7720
+ mergeDicts(
6769
7721
  {
6770
7722
  name: "Chat Completion",
6771
7723
  spanAttributes: {
6772
- type: SpanTypeAttribute2.LLM
7724
+ type: "llm" /* LLM */
6773
7725
  }
6774
7726
  },
6775
7727
  parseChatCompletionParams(allParams)
@@ -6789,11 +7741,11 @@ function wrapBetaChatCompletionStream(completion) {
6789
7741
  return (allParams) => {
6790
7742
  const { span_info: _, ...params } = allParams;
6791
7743
  const span = startSpan(
6792
- mergeDicts2(
7744
+ mergeDicts(
6793
7745
  {
6794
7746
  name: "Chat Completion",
6795
7747
  spanAttributes: {
6796
- type: SpanTypeAttribute2.LLM
7748
+ type: "llm" /* LLM */
6797
7749
  }
6798
7750
  },
6799
7751
  parseChatCompletionParams(allParams)
@@ -6852,15 +7804,16 @@ function wrapChatCompletion(completion) {
6852
7804
  return (allParams, options) => {
6853
7805
  const { span_info: _, ...params } = allParams;
6854
7806
  let executionPromise = null;
6855
- const executeWrapped = () => {
7807
+ let dataPromise = null;
7808
+ const ensureExecuted = () => {
6856
7809
  if (!executionPromise) {
6857
7810
  executionPromise = (async () => {
6858
7811
  const span = startSpan(
6859
- mergeDicts2(
7812
+ mergeDicts(
6860
7813
  {
6861
7814
  name: "Chat Completion",
6862
7815
  spanAttributes: {
6863
- type: SpanTypeAttribute2.LLM
7816
+ type: "llm" /* LLM */
6864
7817
  }
6865
7818
  },
6866
7819
  parseChatCompletionParams(allParams)
@@ -6910,17 +7863,19 @@ function wrapChatCompletion(completion) {
6910
7863
  }
6911
7864
  return executionPromise;
6912
7865
  };
6913
- const dataPromise = executeWrapped().then((result) => result.data);
6914
- return new Proxy(dataPromise, {
7866
+ return new Proxy({}, {
6915
7867
  get(target, prop, receiver) {
6916
7868
  if (prop === "withResponse") {
6917
- return executeWrapped;
7869
+ return () => ensureExecuted();
6918
7870
  }
6919
- const value = Reflect.get(target, prop, receiver);
6920
- if (typeof value === "function") {
6921
- return value.bind(target);
7871
+ if (prop === "then" || prop === "catch" || prop === "finally" || prop in Promise.prototype) {
7872
+ if (!dataPromise) {
7873
+ dataPromise = ensureExecuted().then((result) => result.data);
7874
+ }
7875
+ const value = Reflect.get(dataPromise, prop, receiver);
7876
+ return typeof value === "function" ? value.bind(dataPromise) : value;
6922
7877
  }
6923
- return value;
7878
+ return Reflect.get(target, prop, receiver);
6924
7879
  }
6925
7880
  });
6926
7881
  };
@@ -6937,7 +7892,7 @@ function parseBaseParams(allParams, inputField) {
6937
7892
  const input = params[inputField];
6938
7893
  const paramsRest = { ...params, provider: "openai" };
6939
7894
  delete paramsRest[inputField];
6940
- return mergeDicts2(ret, { event: { input, metadata: paramsRest } });
7895
+ return mergeDicts(ret, { event: { input, metadata: paramsRest } });
6941
7896
  }
6942
7897
  function createApiWrapper(name, create, processResponse, parseParams) {
6943
7898
  return async (allParams, options) => {
@@ -6952,11 +7907,11 @@ function createApiWrapper(name, create, processResponse, parseParams) {
6952
7907
  processResponse(result, span);
6953
7908
  return result;
6954
7909
  },
6955
- mergeDicts2(
7910
+ mergeDicts(
6956
7911
  {
6957
7912
  name,
6958
7913
  spanAttributes: {
6959
- type: SpanTypeAttribute2.LLM
7914
+ type: "llm" /* LLM */
6960
7915
  }
6961
7916
  },
6962
7917
  parseParams(allParams)
@@ -7095,44 +8050,44 @@ var WrapperStream = class {
7095
8050
  };
7096
8051
 
7097
8052
  // dev/types.ts
7098
- import { z as z4 } from "zod";
7099
- var evalBodySchema = z4.object({
7100
- name: z4.string(),
7101
- parameters: z4.record(z4.string(), z4.unknown()).nullish(),
8053
+ import { z as z8 } from "zod/v3";
8054
+ var evalBodySchema = z8.object({
8055
+ name: z8.string(),
8056
+ parameters: z8.record(z8.string(), z8.unknown()).nullish(),
7102
8057
  data: RunEval.shape.data,
7103
- scores: z4.array(
7104
- z4.object({
8058
+ scores: z8.array(
8059
+ z8.object({
7105
8060
  function_id: FunctionId,
7106
- name: z4.string()
8061
+ name: z8.string()
7107
8062
  })
7108
8063
  ).nullish(),
7109
- experiment_name: z4.string().nullish(),
7110
- project_id: z4.string().nullish(),
8064
+ experiment_name: z8.string().nullish(),
8065
+ project_id: z8.string().nullish(),
7111
8066
  parent: InvokeParent.optional(),
7112
- stream: z4.boolean().optional()
8067
+ stream: z8.boolean().optional()
7113
8068
  });
7114
- var evalParametersSerializedSchema = z4.record(
7115
- z4.string(),
7116
- z4.union([
7117
- z4.object({
7118
- type: z4.literal("prompt"),
8069
+ var evalParametersSerializedSchema = z8.record(
8070
+ z8.string(),
8071
+ z8.union([
8072
+ z8.object({
8073
+ type: z8.literal("prompt"),
7119
8074
  default: PromptData.optional(),
7120
- description: z4.string().optional()
8075
+ description: z8.string().optional()
7121
8076
  }),
7122
- z4.object({
7123
- type: z4.literal("data"),
7124
- schema: z4.record(z4.unknown()),
8077
+ z8.object({
8078
+ type: z8.literal("data"),
8079
+ schema: z8.record(z8.unknown()),
7125
8080
  // JSON Schema
7126
- default: z4.unknown().optional(),
7127
- description: z4.string().optional()
8081
+ default: z8.unknown().optional(),
8082
+ description: z8.string().optional()
7128
8083
  })
7129
8084
  ])
7130
8085
  );
7131
- var evaluatorDefinitionSchema = z4.object({
8086
+ var evaluatorDefinitionSchema = z8.object({
7132
8087
  parameters: evalParametersSerializedSchema.optional()
7133
8088
  });
7134
- var evaluatorDefinitionsSchema = z4.record(
7135
- z4.string(),
8089
+ var evaluatorDefinitionsSchema = z8.record(
8090
+ z8.string(),
7136
8091
  evaluatorDefinitionSchema
7137
8092
  );
7138
8093