braintrust 0.3.6 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13;var __defProp = Object.defineProperty;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13;var __defProp = Object.defineProperty;
2
2
  var __export = (target, all) => {
3
3
  for (var name in all)
4
4
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -29,7 +29,7 @@ var iso = {
29
29
  var isomorph_default = iso;
30
30
 
31
31
  // src/logger.ts
32
- var _uuid = require('uuid');
32
+ var _uuid = require('uuid'); var uuid3 = _interopRequireWildcard(_uuid); var uuid2 = _interopRequireWildcard(_uuid); var uuid = _interopRequireWildcard(_uuid);
33
33
 
34
34
  // src/queue.ts
35
35
  var DEFAULT_QUEUE_SIZE = 15e3;
@@ -87,33 +87,990 @@ var Queue = (_class = class {
87
87
  }
88
88
  }, _class);
89
89
 
90
- // src/logger.ts
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
91
99
 
92
100
 
101
+ // util/span_identifier_v2.ts
93
102
 
94
103
 
104
+ // util/span_identifier_v1.ts
95
105
 
106
+ var _v3 = require('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 = _v3.z.nativeEnum(SpanObjectTypeV1);
126
+ var SpanRowIdsV1 = class {
127
+
128
+
129
+
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
+
154
+
155
+
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: _optionalChain([this, 'access', _2 => _2.rowIds, 'optionalAccess', _3 => _3.toObject, 'call', _4 => _4()])
241
+ };
242
+ }
243
+ };
244
+
245
+ // util/span_identifier_v2.ts
246
+
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 = _v3.z.nativeEnum(SpanObjectTypeV2);
267
+ var SpanRowIdsV2 = class {
268
+
269
+
270
+
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
+
295
+
296
+
297
+
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: _optionalChain([this, 'access', _5 => _5.rowIds, 'optionalAccess', _6 => _6.toObject, 'call', _7 => _7()])
455
+ };
456
+ }
457
+ };
96
458
 
459
+ // util/span_identifier_v3.ts
97
460
 
98
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
+ }
99
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 (e2) {
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 = _v3.z.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 = _v3.z.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 = _v3.z.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: _v3.z.record(_v3.z.unknown()).nullish()
553
+ }).and(
554
+ _v3.z.union([
555
+ // Must provide one or the other.
556
+ _v3.z.object({
557
+ object_id: _v3.z.string().nullish(),
558
+ compute_object_metadata_args: _v3.z.optional(_v3.z.null())
559
+ }),
560
+ _v3.z.object({
561
+ object_id: _v3.z.optional(_v3.z.null()),
562
+ compute_object_metadata_args: _v3.z.record(_v3.z.unknown())
563
+ })
564
+ ])
565
+ ).and(
566
+ _v3.z.union([
567
+ // Either all of these must be provided or none.
568
+ _v3.z.object({
569
+ row_id: _v3.z.string(),
570
+ span_id: _v3.z.string(),
571
+ root_span_id: _v3.z.string()
572
+ }),
573
+ _v3.z.object({
574
+ row_id: _v3.z.optional(_v3.z.null()),
575
+ span_id: _v3.z.optional(_v3.z.null()),
576
+ root_span_id: _v3.z.optional(_v3.z.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 (e3) {
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
+ };
100
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
+ }
101
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
+ }
102
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 = _nullishCoalesce(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
+ _optionalChain([lastVisitF, 'optionalCall', _8 => _8(vertex)]);
787
+ continue;
788
+ }
789
+ if (firstVisitedVertices.has(vertex)) {
790
+ continue;
791
+ }
792
+ firstVisitedVertices.add(vertex);
793
+ _optionalChain([firstVisitF, 'optionalCall', _9 => _9(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 = _optionalChain([args, 'optionalAccess', _10 => _10.parentVertex]) !== void 0 ? mapAt(vertexLabels, _optionalChain([args, 'optionalAccess', _11 => _11.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
+ }
103
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
+ _nullishCoalesce(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 = _nullishCoalesce(args.batchMaxNumItems, () => ( Number.POSITIVE_INFINITY));
943
+ const batchMaxNumBytes = _nullishCoalesce(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
+ }
104
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
+ }
105
1024
 
1025
+ // util/json_util.ts
1026
+ function constructJsonArray(items) {
1027
+ return `[${items.join(",")}]`;
1028
+ }
106
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
+ }
107
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 = (_nullishCoalesce(s1.fields, () => ( []))).filter((f) => (_nullishCoalesce(s2.fields, () => ( []))).includes(f));
1049
+ const collect = fields.length > 0 ? "some" : "none";
1050
+ return { collect, fields };
1051
+ }
108
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
+ }
109
1066
 
1067
+ // util/zod_util.ts
110
1068
 
111
- var _core = require('@braintrust/core');
112
1069
 
113
1070
  // src/generated_types.ts
114
- var _zod = require('zod');
115
- var AclObjectType = _zod.z.union([
116
- _zod.z.enum([
1071
+
1072
+ var AclObjectType = _v3.z.union([
1073
+ _v3.z.enum([
117
1074
  "organization",
118
1075
  "project",
119
1076
  "experiment",
@@ -126,9 +1083,9 @@ var AclObjectType = _zod.z.union([
126
1083
  "project_log",
127
1084
  "org_project"
128
1085
  ]),
129
- _zod.z.null()
1086
+ _v3.z.null()
130
1087
  ]);
131
- var Permission = _zod.z.enum([
1088
+ var Permission = _v3.z.enum([
132
1089
  "create",
133
1090
  "read",
134
1091
  "update",
@@ -138,310 +1095,310 @@ var Permission = _zod.z.enum([
138
1095
  "update_acls",
139
1096
  "delete_acls"
140
1097
  ]);
141
- var Acl = _zod.z.object({
142
- id: _zod.z.string().uuid(),
143
- object_type: AclObjectType.and(_zod.z.string()),
144
- object_id: _zod.z.string().uuid(),
145
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
146
- group_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
147
- permission: Permission.and(_zod.z.union([_zod.z.string(), _zod.z.null()])).optional(),
148
- restrict_object_type: AclObjectType.and(_zod.z.unknown()).optional(),
149
- role_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
150
- _object_org_id: _zod.z.string().uuid(),
151
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1098
+ var Acl = _v3.z.object({
1099
+ id: _v3.z.string().uuid(),
1100
+ object_type: AclObjectType.and(_v3.z.string()),
1101
+ object_id: _v3.z.string().uuid(),
1102
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1103
+ group_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1104
+ permission: Permission.and(_v3.z.union([_v3.z.string(), _v3.z.null()])).optional(),
1105
+ restrict_object_type: AclObjectType.and(_v3.z.unknown()).optional(),
1106
+ role_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1107
+ _object_org_id: _v3.z.string().uuid(),
1108
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
152
1109
  });
153
- var AISecret = _zod.z.object({
154
- id: _zod.z.string().uuid(),
155
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
156
- updated_at: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
157
- org_id: _zod.z.string().uuid(),
158
- name: _zod.z.string(),
159
- type: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
160
- metadata: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.null()]).optional(),
161
- preview_secret: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1110
+ var AISecret = _v3.z.object({
1111
+ id: _v3.z.string().uuid(),
1112
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1113
+ updated_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1114
+ org_id: _v3.z.string().uuid(),
1115
+ name: _v3.z.string(),
1116
+ type: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1117
+ metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional(),
1118
+ preview_secret: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
162
1119
  });
163
- var ResponseFormatJsonSchema = _zod.z.object({
164
- name: _zod.z.string(),
165
- description: _zod.z.string().optional(),
166
- schema: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.string()]).optional(),
167
- strict: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional()
1120
+ var ResponseFormatJsonSchema = _v3.z.object({
1121
+ name: _v3.z.string(),
1122
+ description: _v3.z.string().optional(),
1123
+ schema: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.string()]).optional(),
1124
+ strict: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
168
1125
  });
169
- var ResponseFormatNullish = _zod.z.union([
170
- _zod.z.object({ type: _zod.z.literal("json_object") }),
171
- _zod.z.object({
172
- type: _zod.z.literal("json_schema"),
1126
+ var ResponseFormatNullish = _v3.z.union([
1127
+ _v3.z.object({ type: _v3.z.literal("json_object") }),
1128
+ _v3.z.object({
1129
+ type: _v3.z.literal("json_schema"),
173
1130
  json_schema: ResponseFormatJsonSchema
174
1131
  }),
175
- _zod.z.object({ type: _zod.z.literal("text") }),
176
- _zod.z.null()
1132
+ _v3.z.object({ type: _v3.z.literal("text") }),
1133
+ _v3.z.null()
177
1134
  ]);
178
- var AnyModelParams = _zod.z.object({
179
- temperature: _zod.z.number().optional(),
180
- top_p: _zod.z.number().optional(),
181
- max_tokens: _zod.z.number(),
182
- max_completion_tokens: _zod.z.number().optional(),
183
- frequency_penalty: _zod.z.number().optional(),
184
- presence_penalty: _zod.z.number().optional(),
1135
+ var AnyModelParams = _v3.z.object({
1136
+ temperature: _v3.z.number().optional(),
1137
+ top_p: _v3.z.number().optional(),
1138
+ max_tokens: _v3.z.number(),
1139
+ max_completion_tokens: _v3.z.number().optional(),
1140
+ frequency_penalty: _v3.z.number().optional(),
1141
+ presence_penalty: _v3.z.number().optional(),
185
1142
  response_format: ResponseFormatNullish.optional(),
186
- tool_choice: _zod.z.union([
187
- _zod.z.literal("auto"),
188
- _zod.z.literal("none"),
189
- _zod.z.literal("required"),
190
- _zod.z.object({
191
- type: _zod.z.literal("function"),
192
- function: _zod.z.object({ name: _zod.z.string() })
1143
+ tool_choice: _v3.z.union([
1144
+ _v3.z.literal("auto"),
1145
+ _v3.z.literal("none"),
1146
+ _v3.z.literal("required"),
1147
+ _v3.z.object({
1148
+ type: _v3.z.literal("function"),
1149
+ function: _v3.z.object({ name: _v3.z.string() })
193
1150
  })
194
1151
  ]).optional(),
195
- function_call: _zod.z.union([
196
- _zod.z.literal("auto"),
197
- _zod.z.literal("none"),
198
- _zod.z.object({ name: _zod.z.string() })
1152
+ function_call: _v3.z.union([
1153
+ _v3.z.literal("auto"),
1154
+ _v3.z.literal("none"),
1155
+ _v3.z.object({ name: _v3.z.string() })
199
1156
  ]).optional(),
200
- n: _zod.z.number().optional(),
201
- stop: _zod.z.array(_zod.z.string()).optional(),
202
- reasoning_effort: _zod.z.enum(["minimal", "low", "medium", "high"]).optional(),
203
- verbosity: _zod.z.enum(["low", "medium", "high"]).optional(),
204
- top_k: _zod.z.number().optional(),
205
- stop_sequences: _zod.z.array(_zod.z.string()).optional(),
206
- max_tokens_to_sample: _zod.z.number().optional(),
207
- maxOutputTokens: _zod.z.number().optional(),
208
- topP: _zod.z.number().optional(),
209
- topK: _zod.z.number().optional(),
210
- use_cache: _zod.z.boolean().optional()
1157
+ n: _v3.z.number().optional(),
1158
+ stop: _v3.z.array(_v3.z.string()).optional(),
1159
+ reasoning_effort: _v3.z.enum(["minimal", "low", "medium", "high"]).optional(),
1160
+ verbosity: _v3.z.enum(["low", "medium", "high"]).optional(),
1161
+ top_k: _v3.z.number().optional(),
1162
+ stop_sequences: _v3.z.array(_v3.z.string()).optional(),
1163
+ max_tokens_to_sample: _v3.z.number().optional(),
1164
+ maxOutputTokens: _v3.z.number().optional(),
1165
+ topP: _v3.z.number().optional(),
1166
+ topK: _v3.z.number().optional(),
1167
+ use_cache: _v3.z.boolean().optional()
211
1168
  });
212
- var ApiKey = _zod.z.object({
213
- id: _zod.z.string().uuid(),
214
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
215
- name: _zod.z.string(),
216
- preview_name: _zod.z.string(),
217
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
218
- user_email: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
219
- user_given_name: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
220
- user_family_name: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
221
- org_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1169
+ var ApiKey = _v3.z.object({
1170
+ id: _v3.z.string().uuid(),
1171
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1172
+ name: _v3.z.string(),
1173
+ preview_name: _v3.z.string(),
1174
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1175
+ user_email: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1176
+ user_given_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1177
+ user_family_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1178
+ org_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
222
1179
  });
223
- var AsyncScoringState = _zod.z.union([
224
- _zod.z.object({
225
- status: _zod.z.literal("enabled"),
226
- token: _zod.z.string(),
227
- function_ids: _zod.z.array(_zod.z.unknown()).min(1),
228
- skip_logging: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional()
1180
+ var AsyncScoringState = _v3.z.union([
1181
+ _v3.z.object({
1182
+ status: _v3.z.literal("enabled"),
1183
+ token: _v3.z.string(),
1184
+ function_ids: _v3.z.array(_v3.z.unknown()).min(1),
1185
+ skip_logging: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
229
1186
  }),
230
- _zod.z.object({ status: _zod.z.literal("disabled") }),
231
- _zod.z.null(),
232
- _zod.z.null()
1187
+ _v3.z.object({ status: _v3.z.literal("disabled") }),
1188
+ _v3.z.null(),
1189
+ _v3.z.null()
233
1190
  ]);
234
- var AsyncScoringControl = _zod.z.union([
235
- _zod.z.object({ kind: _zod.z.literal("score_update"), token: _zod.z.string() }),
236
- _zod.z.object({ kind: _zod.z.literal("state_override"), state: AsyncScoringState }),
237
- _zod.z.object({ kind: _zod.z.literal("state_force_reselect") }),
238
- _zod.z.object({ kind: _zod.z.literal("state_enabled_force_rescore") })
1191
+ var AsyncScoringControl = _v3.z.union([
1192
+ _v3.z.object({ kind: _v3.z.literal("score_update"), token: _v3.z.string() }),
1193
+ _v3.z.object({ kind: _v3.z.literal("state_override"), state: AsyncScoringState }),
1194
+ _v3.z.object({ kind: _v3.z.literal("state_force_reselect") }),
1195
+ _v3.z.object({ kind: _v3.z.literal("state_enabled_force_rescore") })
239
1196
  ]);
240
- var BraintrustAttachmentReference = _zod.z.object({
241
- type: _zod.z.literal("braintrust_attachment"),
242
- filename: _zod.z.string().min(1),
243
- content_type: _zod.z.string().min(1),
244
- key: _zod.z.string().min(1)
1197
+ var BraintrustAttachmentReference = _v3.z.object({
1198
+ type: _v3.z.literal("braintrust_attachment"),
1199
+ filename: _v3.z.string().min(1),
1200
+ content_type: _v3.z.string().min(1),
1201
+ key: _v3.z.string().min(1)
245
1202
  });
246
- var ExternalAttachmentReference = _zod.z.object({
247
- type: _zod.z.literal("external_attachment"),
248
- filename: _zod.z.string().min(1),
249
- content_type: _zod.z.string().min(1),
250
- url: _zod.z.string().min(1)
1203
+ var ExternalAttachmentReference = _v3.z.object({
1204
+ type: _v3.z.literal("external_attachment"),
1205
+ filename: _v3.z.string().min(1),
1206
+ content_type: _v3.z.string().min(1),
1207
+ url: _v3.z.string().min(1)
251
1208
  });
252
- var AttachmentReference = _zod.z.discriminatedUnion("type", [
1209
+ var AttachmentReference = _v3.z.discriminatedUnion("type", [
253
1210
  BraintrustAttachmentReference,
254
1211
  ExternalAttachmentReference
255
1212
  ]);
256
- var UploadStatus = _zod.z.enum(["uploading", "done", "error"]);
257
- var AttachmentStatus = _zod.z.object({
1213
+ var UploadStatus = _v3.z.enum(["uploading", "done", "error"]);
1214
+ var AttachmentStatus = _v3.z.object({
258
1215
  upload_status: UploadStatus,
259
- error_message: _zod.z.string().optional()
1216
+ error_message: _v3.z.string().optional()
260
1217
  });
261
- var BraintrustModelParams = _zod.z.object({ use_cache: _zod.z.boolean() }).partial();
262
- var CallEvent = _zod.z.union([
263
- _zod.z.object({
264
- id: _zod.z.string().optional(),
265
- data: _zod.z.string(),
266
- event: _zod.z.literal("text_delta")
1218
+ var BraintrustModelParams = _v3.z.object({ use_cache: _v3.z.boolean() }).partial();
1219
+ var CallEvent = _v3.z.union([
1220
+ _v3.z.object({
1221
+ id: _v3.z.string().optional(),
1222
+ data: _v3.z.string(),
1223
+ event: _v3.z.literal("text_delta")
267
1224
  }),
268
- _zod.z.object({
269
- id: _zod.z.string().optional(),
270
- data: _zod.z.string(),
271
- event: _zod.z.literal("reasoning_delta")
1225
+ _v3.z.object({
1226
+ id: _v3.z.string().optional(),
1227
+ data: _v3.z.string(),
1228
+ event: _v3.z.literal("reasoning_delta")
272
1229
  }),
273
- _zod.z.object({
274
- id: _zod.z.string().optional(),
275
- data: _zod.z.string(),
276
- event: _zod.z.literal("json_delta")
1230
+ _v3.z.object({
1231
+ id: _v3.z.string().optional(),
1232
+ data: _v3.z.string(),
1233
+ event: _v3.z.literal("json_delta")
277
1234
  }),
278
- _zod.z.object({
279
- id: _zod.z.string().optional(),
280
- data: _zod.z.string(),
281
- event: _zod.z.literal("progress")
1235
+ _v3.z.object({
1236
+ id: _v3.z.string().optional(),
1237
+ data: _v3.z.string(),
1238
+ event: _v3.z.literal("progress")
282
1239
  }),
283
- _zod.z.object({
284
- id: _zod.z.string().optional(),
285
- data: _zod.z.string(),
286
- event: _zod.z.literal("error")
1240
+ _v3.z.object({
1241
+ id: _v3.z.string().optional(),
1242
+ data: _v3.z.string(),
1243
+ event: _v3.z.literal("error")
287
1244
  }),
288
- _zod.z.object({
289
- id: _zod.z.string().optional(),
290
- data: _zod.z.string(),
291
- event: _zod.z.literal("console")
1245
+ _v3.z.object({
1246
+ id: _v3.z.string().optional(),
1247
+ data: _v3.z.string(),
1248
+ event: _v3.z.literal("console")
292
1249
  }),
293
- _zod.z.object({
294
- id: _zod.z.string().optional(),
295
- event: _zod.z.literal("start"),
296
- data: _zod.z.literal("")
1250
+ _v3.z.object({
1251
+ id: _v3.z.string().optional(),
1252
+ event: _v3.z.literal("start"),
1253
+ data: _v3.z.literal("")
297
1254
  }),
298
- _zod.z.object({
299
- id: _zod.z.string().optional(),
300
- event: _zod.z.literal("done"),
301
- data: _zod.z.literal("")
1255
+ _v3.z.object({
1256
+ id: _v3.z.string().optional(),
1257
+ event: _v3.z.literal("done"),
1258
+ data: _v3.z.literal("")
302
1259
  })
303
1260
  ]);
304
- var ChatCompletionContentPartTextWithTitle = _zod.z.object({
305
- text: _zod.z.string().default(""),
306
- type: _zod.z.literal("text"),
307
- cache_control: _zod.z.object({ type: _zod.z.literal("ephemeral") }).optional()
1261
+ var ChatCompletionContentPartTextWithTitle = _v3.z.object({
1262
+ text: _v3.z.string().default(""),
1263
+ type: _v3.z.literal("text"),
1264
+ cache_control: _v3.z.object({ type: _v3.z.literal("ephemeral") }).optional()
308
1265
  });
309
- var ChatCompletionContentPartImageWithTitle = _zod.z.object({
310
- image_url: _zod.z.object({
311
- url: _zod.z.string(),
312
- detail: _zod.z.union([_zod.z.literal("auto"), _zod.z.literal("low"), _zod.z.literal("high")]).optional()
1266
+ var ChatCompletionContentPartImageWithTitle = _v3.z.object({
1267
+ image_url: _v3.z.object({
1268
+ url: _v3.z.string(),
1269
+ detail: _v3.z.union([_v3.z.literal("auto"), _v3.z.literal("low"), _v3.z.literal("high")]).optional()
313
1270
  }),
314
- type: _zod.z.literal("image_url")
1271
+ type: _v3.z.literal("image_url")
315
1272
  });
316
- var ChatCompletionContentPart = _zod.z.union([
1273
+ var ChatCompletionContentPart = _v3.z.union([
317
1274
  ChatCompletionContentPartTextWithTitle,
318
1275
  ChatCompletionContentPartImageWithTitle
319
1276
  ]);
320
- var ChatCompletionContentPartText = _zod.z.object({
321
- text: _zod.z.string().default(""),
322
- type: _zod.z.literal("text"),
323
- cache_control: _zod.z.object({ type: _zod.z.literal("ephemeral") }).optional()
1277
+ var ChatCompletionContentPartText = _v3.z.object({
1278
+ text: _v3.z.string().default(""),
1279
+ type: _v3.z.literal("text"),
1280
+ cache_control: _v3.z.object({ type: _v3.z.literal("ephemeral") }).optional()
324
1281
  });
325
- var ChatCompletionMessageToolCall = _zod.z.object({
326
- id: _zod.z.string(),
327
- function: _zod.z.object({ arguments: _zod.z.string(), name: _zod.z.string() }),
328
- type: _zod.z.literal("function")
1282
+ var ChatCompletionMessageToolCall = _v3.z.object({
1283
+ id: _v3.z.string(),
1284
+ function: _v3.z.object({ arguments: _v3.z.string(), name: _v3.z.string() }),
1285
+ type: _v3.z.literal("function")
329
1286
  });
330
- var ChatCompletionMessageReasoning = _zod.z.object({ id: _zod.z.string(), content: _zod.z.string() }).partial();
331
- var ChatCompletionMessageParam = _zod.z.union([
332
- _zod.z.object({
333
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPartText)]),
334
- role: _zod.z.literal("system"),
335
- name: _zod.z.string().optional()
1287
+ var ChatCompletionMessageReasoning = _v3.z.object({ id: _v3.z.string(), content: _v3.z.string() }).partial();
1288
+ var ChatCompletionMessageParam = _v3.z.union([
1289
+ _v3.z.object({
1290
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
1291
+ role: _v3.z.literal("system"),
1292
+ name: _v3.z.string().optional()
336
1293
  }),
337
- _zod.z.object({
338
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPart)]),
339
- role: _zod.z.literal("user"),
340
- name: _zod.z.string().optional()
1294
+ _v3.z.object({
1295
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPart)]),
1296
+ role: _v3.z.literal("user"),
1297
+ name: _v3.z.string().optional()
341
1298
  }),
342
- _zod.z.object({
343
- role: _zod.z.literal("assistant"),
344
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPartText), _zod.z.null()]).optional(),
345
- function_call: _zod.z.object({ arguments: _zod.z.string(), name: _zod.z.string() }).optional(),
346
- name: _zod.z.string().optional(),
347
- tool_calls: _zod.z.array(ChatCompletionMessageToolCall).optional(),
348
- reasoning: _zod.z.array(ChatCompletionMessageReasoning).optional()
1299
+ _v3.z.object({
1300
+ role: _v3.z.literal("assistant"),
1301
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText), _v3.z.null()]).optional(),
1302
+ function_call: _v3.z.object({ arguments: _v3.z.string(), name: _v3.z.string() }).optional(),
1303
+ name: _v3.z.string().optional(),
1304
+ tool_calls: _v3.z.array(ChatCompletionMessageToolCall).optional(),
1305
+ reasoning: _v3.z.array(ChatCompletionMessageReasoning).optional()
349
1306
  }),
350
- _zod.z.object({
351
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPartText)]),
352
- role: _zod.z.literal("tool"),
353
- tool_call_id: _zod.z.string().default("")
1307
+ _v3.z.object({
1308
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
1309
+ role: _v3.z.literal("tool"),
1310
+ tool_call_id: _v3.z.string().default("")
354
1311
  }),
355
- _zod.z.object({
356
- content: _zod.z.union([_zod.z.string(), _zod.z.null()]),
357
- name: _zod.z.string(),
358
- role: _zod.z.literal("function")
1312
+ _v3.z.object({
1313
+ content: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1314
+ name: _v3.z.string(),
1315
+ role: _v3.z.literal("function")
359
1316
  }),
360
- _zod.z.object({
361
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPartText)]),
362
- role: _zod.z.literal("developer"),
363
- name: _zod.z.string().optional()
1317
+ _v3.z.object({
1318
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
1319
+ role: _v3.z.literal("developer"),
1320
+ name: _v3.z.string().optional()
364
1321
  }),
365
- _zod.z.object({
366
- role: _zod.z.literal("model"),
367
- content: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1322
+ _v3.z.object({
1323
+ role: _v3.z.literal("model"),
1324
+ content: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
368
1325
  })
369
1326
  ]);
370
- var ChatCompletionOpenAIMessageParam = _zod.z.union([
371
- _zod.z.object({
372
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPartText)]),
373
- role: _zod.z.literal("system"),
374
- name: _zod.z.string().optional()
1327
+ var ChatCompletionOpenAIMessageParam = _v3.z.union([
1328
+ _v3.z.object({
1329
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
1330
+ role: _v3.z.literal("system"),
1331
+ name: _v3.z.string().optional()
375
1332
  }),
376
- _zod.z.object({
377
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPart)]),
378
- role: _zod.z.literal("user"),
379
- name: _zod.z.string().optional()
1333
+ _v3.z.object({
1334
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPart)]),
1335
+ role: _v3.z.literal("user"),
1336
+ name: _v3.z.string().optional()
380
1337
  }),
381
- _zod.z.object({
382
- role: _zod.z.literal("assistant"),
383
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPartText), _zod.z.null()]).optional(),
384
- function_call: _zod.z.object({ arguments: _zod.z.string(), name: _zod.z.string() }).optional(),
385
- name: _zod.z.string().optional(),
386
- tool_calls: _zod.z.array(ChatCompletionMessageToolCall).optional(),
387
- reasoning: _zod.z.array(ChatCompletionMessageReasoning).optional()
1338
+ _v3.z.object({
1339
+ role: _v3.z.literal("assistant"),
1340
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText), _v3.z.null()]).optional(),
1341
+ function_call: _v3.z.object({ arguments: _v3.z.string(), name: _v3.z.string() }).optional(),
1342
+ name: _v3.z.string().optional(),
1343
+ tool_calls: _v3.z.array(ChatCompletionMessageToolCall).optional(),
1344
+ reasoning: _v3.z.array(ChatCompletionMessageReasoning).optional()
388
1345
  }),
389
- _zod.z.object({
390
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPartText)]),
391
- role: _zod.z.literal("tool"),
392
- tool_call_id: _zod.z.string().default("")
1346
+ _v3.z.object({
1347
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
1348
+ role: _v3.z.literal("tool"),
1349
+ tool_call_id: _v3.z.string().default("")
393
1350
  }),
394
- _zod.z.object({
395
- content: _zod.z.union([_zod.z.string(), _zod.z.null()]),
396
- name: _zod.z.string(),
397
- role: _zod.z.literal("function")
1351
+ _v3.z.object({
1352
+ content: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1353
+ name: _v3.z.string(),
1354
+ role: _v3.z.literal("function")
398
1355
  }),
399
- _zod.z.object({
400
- content: _zod.z.union([_zod.z.string(), _zod.z.array(ChatCompletionContentPartText)]),
401
- role: _zod.z.literal("developer"),
402
- name: _zod.z.string().optional()
1356
+ _v3.z.object({
1357
+ content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
1358
+ role: _v3.z.literal("developer"),
1359
+ name: _v3.z.string().optional()
403
1360
  })
404
1361
  ]);
405
- var ChatCompletionTool = _zod.z.object({
406
- function: _zod.z.object({
407
- name: _zod.z.string(),
408
- description: _zod.z.string().optional(),
409
- parameters: _zod.z.object({}).partial().passthrough().optional()
1362
+ var ChatCompletionTool = _v3.z.object({
1363
+ function: _v3.z.object({
1364
+ name: _v3.z.string(),
1365
+ description: _v3.z.string().optional(),
1366
+ parameters: _v3.z.object({}).partial().passthrough().optional()
410
1367
  }),
411
- type: _zod.z.literal("function")
1368
+ type: _v3.z.literal("function")
412
1369
  });
413
- var CodeBundle = _zod.z.object({
414
- runtime_context: _zod.z.object({
415
- runtime: _zod.z.enum(["node", "python"]),
416
- version: _zod.z.string()
1370
+ var CodeBundle = _v3.z.object({
1371
+ runtime_context: _v3.z.object({
1372
+ runtime: _v3.z.enum(["node", "python"]),
1373
+ version: _v3.z.string()
417
1374
  }),
418
- location: _zod.z.union([
419
- _zod.z.object({
420
- type: _zod.z.literal("experiment"),
421
- eval_name: _zod.z.string(),
422
- position: _zod.z.union([
423
- _zod.z.object({ type: _zod.z.literal("task") }),
424
- _zod.z.object({ type: _zod.z.literal("scorer"), index: _zod.z.number().int().gte(0) })
1375
+ location: _v3.z.union([
1376
+ _v3.z.object({
1377
+ type: _v3.z.literal("experiment"),
1378
+ eval_name: _v3.z.string(),
1379
+ position: _v3.z.union([
1380
+ _v3.z.object({ type: _v3.z.literal("task") }),
1381
+ _v3.z.object({ type: _v3.z.literal("scorer"), index: _v3.z.number().int().gte(0) })
425
1382
  ])
426
1383
  }),
427
- _zod.z.object({ type: _zod.z.literal("function"), index: _zod.z.number().int().gte(0) })
1384
+ _v3.z.object({ type: _v3.z.literal("function"), index: _v3.z.number().int().gte(0) })
428
1385
  ]),
429
- bundle_id: _zod.z.string(),
430
- preview: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1386
+ bundle_id: _v3.z.string(),
1387
+ preview: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
431
1388
  });
432
- var Dataset = _zod.z.object({
433
- id: _zod.z.string().uuid(),
434
- project_id: _zod.z.string().uuid(),
435
- name: _zod.z.string(),
436
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
437
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
438
- deleted_at: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
439
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
440
- metadata: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.null()]).optional()
1389
+ var Dataset = _v3.z.object({
1390
+ id: _v3.z.string().uuid(),
1391
+ project_id: _v3.z.string().uuid(),
1392
+ name: _v3.z.string(),
1393
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1394
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1395
+ deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1396
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1397
+ metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional()
441
1398
  });
442
- var ObjectReferenceNullish = _zod.z.union([
443
- _zod.z.object({
444
- object_type: _zod.z.enum([
1399
+ var ObjectReferenceNullish = _v3.z.union([
1400
+ _v3.z.object({
1401
+ object_type: _v3.z.enum([
445
1402
  "project_logs",
446
1403
  "experiment",
447
1404
  "dataset",
@@ -449,399 +1406,399 @@ var ObjectReferenceNullish = _zod.z.union([
449
1406
  "function",
450
1407
  "prompt_session"
451
1408
  ]),
452
- object_id: _zod.z.string().uuid(),
453
- id: _zod.z.string(),
454
- _xact_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
455
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1409
+ object_id: _v3.z.string().uuid(),
1410
+ id: _v3.z.string(),
1411
+ _xact_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1412
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
456
1413
  }),
457
- _zod.z.null()
1414
+ _v3.z.null()
458
1415
  ]);
459
- var DatasetEvent = _zod.z.object({
460
- id: _zod.z.string(),
461
- _xact_id: _zod.z.string(),
462
- created: _zod.z.string().datetime({ offset: true }),
463
- _pagination_key: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
464
- project_id: _zod.z.string().uuid(),
465
- dataset_id: _zod.z.string().uuid(),
466
- input: _zod.z.unknown().optional(),
467
- expected: _zod.z.unknown().optional(),
468
- metadata: _zod.z.union([
469
- _zod.z.object({ model: _zod.z.union([_zod.z.string(), _zod.z.null()]) }).partial().passthrough(),
470
- _zod.z.null()
1416
+ var DatasetEvent = _v3.z.object({
1417
+ id: _v3.z.string(),
1418
+ _xact_id: _v3.z.string(),
1419
+ created: _v3.z.string().datetime({ offset: true }),
1420
+ _pagination_key: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1421
+ project_id: _v3.z.string().uuid(),
1422
+ dataset_id: _v3.z.string().uuid(),
1423
+ input: _v3.z.unknown().optional(),
1424
+ expected: _v3.z.unknown().optional(),
1425
+ metadata: _v3.z.union([
1426
+ _v3.z.object({ model: _v3.z.union([_v3.z.string(), _v3.z.null()]) }).partial().passthrough(),
1427
+ _v3.z.null()
471
1428
  ]).optional(),
472
- tags: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional(),
473
- span_id: _zod.z.string(),
474
- root_span_id: _zod.z.string(),
475
- is_root: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional(),
1429
+ tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
1430
+ span_id: _v3.z.string(),
1431
+ root_span_id: _v3.z.string(),
1432
+ is_root: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
476
1433
  origin: ObjectReferenceNullish.optional()
477
1434
  });
478
- var EnvVar = _zod.z.object({
479
- id: _zod.z.string().uuid(),
480
- object_type: _zod.z.enum(["organization", "project", "function"]),
481
- object_id: _zod.z.string().uuid(),
482
- name: _zod.z.string(),
483
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
484
- used: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1435
+ var EnvVar = _v3.z.object({
1436
+ id: _v3.z.string().uuid(),
1437
+ object_type: _v3.z.enum(["organization", "project", "function"]),
1438
+ object_id: _v3.z.string().uuid(),
1439
+ name: _v3.z.string(),
1440
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1441
+ used: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
485
1442
  });
486
- var RepoInfo = _zod.z.union([
487
- _zod.z.object({
488
- commit: _zod.z.union([_zod.z.string(), _zod.z.null()]),
489
- branch: _zod.z.union([_zod.z.string(), _zod.z.null()]),
490
- tag: _zod.z.union([_zod.z.string(), _zod.z.null()]),
491
- dirty: _zod.z.union([_zod.z.boolean(), _zod.z.null()]),
492
- author_name: _zod.z.union([_zod.z.string(), _zod.z.null()]),
493
- author_email: _zod.z.union([_zod.z.string(), _zod.z.null()]),
494
- commit_message: _zod.z.union([_zod.z.string(), _zod.z.null()]),
495
- commit_time: _zod.z.union([_zod.z.string(), _zod.z.null()]),
496
- git_diff: _zod.z.union([_zod.z.string(), _zod.z.null()])
1443
+ var RepoInfo = _v3.z.union([
1444
+ _v3.z.object({
1445
+ commit: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1446
+ branch: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1447
+ tag: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1448
+ dirty: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
1449
+ author_name: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1450
+ author_email: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1451
+ commit_message: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1452
+ commit_time: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1453
+ git_diff: _v3.z.union([_v3.z.string(), _v3.z.null()])
497
1454
  }).partial(),
498
- _zod.z.null()
1455
+ _v3.z.null()
499
1456
  ]);
500
- var Experiment = _zod.z.object({
501
- id: _zod.z.string().uuid(),
502
- project_id: _zod.z.string().uuid(),
503
- name: _zod.z.string(),
504
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
505
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1457
+ var Experiment = _v3.z.object({
1458
+ id: _v3.z.string().uuid(),
1459
+ project_id: _v3.z.string().uuid(),
1460
+ name: _v3.z.string(),
1461
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1462
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
506
1463
  repo_info: RepoInfo.optional(),
507
- commit: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
508
- base_exp_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
509
- deleted_at: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
510
- dataset_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
511
- dataset_version: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
512
- public: _zod.z.boolean(),
513
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
514
- metadata: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.null()]).optional(),
515
- tags: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional()
1464
+ commit: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1465
+ base_exp_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1466
+ deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1467
+ dataset_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1468
+ dataset_version: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1469
+ public: _v3.z.boolean(),
1470
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1471
+ metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional(),
1472
+ tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional()
516
1473
  });
517
- var SpanType = _zod.z.union([
518
- _zod.z.enum(["llm", "score", "function", "eval", "task", "tool"]),
519
- _zod.z.null()
1474
+ var SpanType = _v3.z.union([
1475
+ _v3.z.enum(["llm", "score", "function", "eval", "task", "tool"]),
1476
+ _v3.z.null()
520
1477
  ]);
521
- var SpanAttributes = _zod.z.union([
522
- _zod.z.object({ name: _zod.z.union([_zod.z.string(), _zod.z.null()]), type: SpanType }).partial().passthrough(),
523
- _zod.z.null()
1478
+ var SpanAttributes = _v3.z.union([
1479
+ _v3.z.object({ name: _v3.z.union([_v3.z.string(), _v3.z.null()]), type: SpanType }).partial().passthrough(),
1480
+ _v3.z.null()
524
1481
  ]);
525
- var ExperimentEvent = _zod.z.object({
526
- id: _zod.z.string(),
527
- _xact_id: _zod.z.string(),
528
- created: _zod.z.string().datetime({ offset: true }),
529
- _pagination_key: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
530
- project_id: _zod.z.string().uuid(),
531
- experiment_id: _zod.z.string().uuid(),
532
- input: _zod.z.unknown().optional(),
533
- output: _zod.z.unknown().optional(),
534
- expected: _zod.z.unknown().optional(),
535
- error: _zod.z.unknown().optional(),
536
- scores: _zod.z.union([_zod.z.record(_zod.z.union([_zod.z.number(), _zod.z.null()])), _zod.z.null()]).optional(),
537
- metadata: _zod.z.union([
538
- _zod.z.object({ model: _zod.z.union([_zod.z.string(), _zod.z.null()]) }).partial().passthrough(),
539
- _zod.z.null()
1482
+ var ExperimentEvent = _v3.z.object({
1483
+ id: _v3.z.string(),
1484
+ _xact_id: _v3.z.string(),
1485
+ created: _v3.z.string().datetime({ offset: true }),
1486
+ _pagination_key: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1487
+ project_id: _v3.z.string().uuid(),
1488
+ experiment_id: _v3.z.string().uuid(),
1489
+ input: _v3.z.unknown().optional(),
1490
+ output: _v3.z.unknown().optional(),
1491
+ expected: _v3.z.unknown().optional(),
1492
+ error: _v3.z.unknown().optional(),
1493
+ scores: _v3.z.union([_v3.z.record(_v3.z.union([_v3.z.number(), _v3.z.null()])), _v3.z.null()]).optional(),
1494
+ metadata: _v3.z.union([
1495
+ _v3.z.object({ model: _v3.z.union([_v3.z.string(), _v3.z.null()]) }).partial().passthrough(),
1496
+ _v3.z.null()
540
1497
  ]).optional(),
541
- tags: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional(),
542
- metrics: _zod.z.union([_zod.z.record(_zod.z.number()), _zod.z.null()]).optional(),
543
- context: _zod.z.union([
544
- _zod.z.object({
545
- caller_functionname: _zod.z.union([_zod.z.string(), _zod.z.null()]),
546
- caller_filename: _zod.z.union([_zod.z.string(), _zod.z.null()]),
547
- caller_lineno: _zod.z.union([_zod.z.number(), _zod.z.null()])
1498
+ tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
1499
+ metrics: _v3.z.union([_v3.z.record(_v3.z.number()), _v3.z.null()]).optional(),
1500
+ context: _v3.z.union([
1501
+ _v3.z.object({
1502
+ caller_functionname: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1503
+ caller_filename: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1504
+ caller_lineno: _v3.z.union([_v3.z.number(), _v3.z.null()])
548
1505
  }).partial().passthrough(),
549
- _zod.z.null()
1506
+ _v3.z.null()
550
1507
  ]).optional(),
551
- span_id: _zod.z.string(),
552
- span_parents: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional(),
553
- root_span_id: _zod.z.string(),
1508
+ span_id: _v3.z.string(),
1509
+ span_parents: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
1510
+ root_span_id: _v3.z.string(),
554
1511
  span_attributes: SpanAttributes.optional(),
555
- is_root: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional(),
1512
+ is_root: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
556
1513
  origin: ObjectReferenceNullish.optional()
557
1514
  });
558
- var ExtendedSavedFunctionId = _zod.z.union([
559
- _zod.z.object({ type: _zod.z.literal("function"), id: _zod.z.string() }),
560
- _zod.z.object({ type: _zod.z.literal("global"), name: _zod.z.string() }),
561
- _zod.z.object({
562
- type: _zod.z.literal("slug"),
563
- project_id: _zod.z.string(),
564
- slug: _zod.z.string()
1515
+ var ExtendedSavedFunctionId = _v3.z.union([
1516
+ _v3.z.object({ type: _v3.z.literal("function"), id: _v3.z.string() }),
1517
+ _v3.z.object({ type: _v3.z.literal("global"), name: _v3.z.string() }),
1518
+ _v3.z.object({
1519
+ type: _v3.z.literal("slug"),
1520
+ project_id: _v3.z.string(),
1521
+ slug: _v3.z.string()
565
1522
  })
566
1523
  ]);
567
- var PromptBlockDataNullish = _zod.z.union([
568
- _zod.z.object({ type: _zod.z.literal("completion"), content: _zod.z.string() }),
569
- _zod.z.object({
570
- type: _zod.z.literal("chat"),
571
- messages: _zod.z.array(ChatCompletionMessageParam),
572
- tools: _zod.z.string().optional()
1524
+ var PromptBlockDataNullish = _v3.z.union([
1525
+ _v3.z.object({ type: _v3.z.literal("completion"), content: _v3.z.string() }),
1526
+ _v3.z.object({
1527
+ type: _v3.z.literal("chat"),
1528
+ messages: _v3.z.array(ChatCompletionMessageParam),
1529
+ tools: _v3.z.string().optional()
573
1530
  }),
574
- _zod.z.null()
1531
+ _v3.z.null()
575
1532
  ]);
576
- var ModelParams = _zod.z.union([
577
- _zod.z.object({
578
- use_cache: _zod.z.boolean(),
579
- temperature: _zod.z.number(),
580
- top_p: _zod.z.number(),
581
- max_tokens: _zod.z.number(),
582
- max_completion_tokens: _zod.z.number(),
583
- frequency_penalty: _zod.z.number(),
584
- presence_penalty: _zod.z.number(),
1533
+ var ModelParams = _v3.z.union([
1534
+ _v3.z.object({
1535
+ use_cache: _v3.z.boolean(),
1536
+ temperature: _v3.z.number(),
1537
+ top_p: _v3.z.number(),
1538
+ max_tokens: _v3.z.number(),
1539
+ max_completion_tokens: _v3.z.number(),
1540
+ frequency_penalty: _v3.z.number(),
1541
+ presence_penalty: _v3.z.number(),
585
1542
  response_format: ResponseFormatNullish,
586
- tool_choice: _zod.z.union([
587
- _zod.z.literal("auto"),
588
- _zod.z.literal("none"),
589
- _zod.z.literal("required"),
590
- _zod.z.object({
591
- type: _zod.z.literal("function"),
592
- function: _zod.z.object({ name: _zod.z.string() })
1543
+ tool_choice: _v3.z.union([
1544
+ _v3.z.literal("auto"),
1545
+ _v3.z.literal("none"),
1546
+ _v3.z.literal("required"),
1547
+ _v3.z.object({
1548
+ type: _v3.z.literal("function"),
1549
+ function: _v3.z.object({ name: _v3.z.string() })
593
1550
  })
594
1551
  ]),
595
- function_call: _zod.z.union([
596
- _zod.z.literal("auto"),
597
- _zod.z.literal("none"),
598
- _zod.z.object({ name: _zod.z.string() })
1552
+ function_call: _v3.z.union([
1553
+ _v3.z.literal("auto"),
1554
+ _v3.z.literal("none"),
1555
+ _v3.z.object({ name: _v3.z.string() })
599
1556
  ]),
600
- n: _zod.z.number(),
601
- stop: _zod.z.array(_zod.z.string()),
602
- reasoning_effort: _zod.z.enum(["minimal", "low", "medium", "high"]),
603
- verbosity: _zod.z.enum(["low", "medium", "high"])
1557
+ n: _v3.z.number(),
1558
+ stop: _v3.z.array(_v3.z.string()),
1559
+ reasoning_effort: _v3.z.enum(["minimal", "low", "medium", "high"]),
1560
+ verbosity: _v3.z.enum(["low", "medium", "high"])
604
1561
  }).partial().passthrough(),
605
- _zod.z.object({
606
- use_cache: _zod.z.boolean().optional(),
607
- max_tokens: _zod.z.number(),
608
- temperature: _zod.z.number(),
609
- top_p: _zod.z.number().optional(),
610
- top_k: _zod.z.number().optional(),
611
- stop_sequences: _zod.z.array(_zod.z.string()).optional(),
612
- max_tokens_to_sample: _zod.z.number().optional()
1562
+ _v3.z.object({
1563
+ use_cache: _v3.z.boolean().optional(),
1564
+ max_tokens: _v3.z.number(),
1565
+ temperature: _v3.z.number(),
1566
+ top_p: _v3.z.number().optional(),
1567
+ top_k: _v3.z.number().optional(),
1568
+ stop_sequences: _v3.z.array(_v3.z.string()).optional(),
1569
+ max_tokens_to_sample: _v3.z.number().optional()
613
1570
  }).passthrough(),
614
- _zod.z.object({
615
- use_cache: _zod.z.boolean(),
616
- temperature: _zod.z.number(),
617
- maxOutputTokens: _zod.z.number(),
618
- topP: _zod.z.number(),
619
- topK: _zod.z.number()
1571
+ _v3.z.object({
1572
+ use_cache: _v3.z.boolean(),
1573
+ temperature: _v3.z.number(),
1574
+ maxOutputTokens: _v3.z.number(),
1575
+ topP: _v3.z.number(),
1576
+ topK: _v3.z.number()
620
1577
  }).partial().passthrough(),
621
- _zod.z.object({
622
- use_cache: _zod.z.boolean(),
623
- temperature: _zod.z.number(),
624
- topK: _zod.z.number()
1578
+ _v3.z.object({
1579
+ use_cache: _v3.z.boolean(),
1580
+ temperature: _v3.z.number(),
1581
+ topK: _v3.z.number()
625
1582
  }).partial().passthrough(),
626
- _zod.z.object({ use_cache: _zod.z.boolean() }).partial().passthrough()
1583
+ _v3.z.object({ use_cache: _v3.z.boolean() }).partial().passthrough()
627
1584
  ]);
628
- var PromptOptionsNullish = _zod.z.union([
629
- _zod.z.object({ model: _zod.z.string(), params: ModelParams, position: _zod.z.string() }).partial(),
630
- _zod.z.null()
1585
+ var PromptOptionsNullish = _v3.z.union([
1586
+ _v3.z.object({ model: _v3.z.string(), params: ModelParams, position: _v3.z.string() }).partial(),
1587
+ _v3.z.null()
631
1588
  ]);
632
- var PromptParserNullish = _zod.z.union([
633
- _zod.z.object({
634
- type: _zod.z.literal("llm_classifier"),
635
- use_cot: _zod.z.boolean(),
636
- choice_scores: _zod.z.record(_zod.z.number().gte(0).lte(1))
1589
+ var PromptParserNullish = _v3.z.union([
1590
+ _v3.z.object({
1591
+ type: _v3.z.literal("llm_classifier"),
1592
+ use_cot: _v3.z.boolean(),
1593
+ choice_scores: _v3.z.record(_v3.z.number().gte(0).lte(1))
637
1594
  }),
638
- _zod.z.null()
1595
+ _v3.z.null()
639
1596
  ]);
640
- var SavedFunctionId = _zod.z.union([
641
- _zod.z.object({ type: _zod.z.literal("function"), id: _zod.z.string() }),
642
- _zod.z.object({ type: _zod.z.literal("global"), name: _zod.z.string() })
1597
+ var SavedFunctionId = _v3.z.union([
1598
+ _v3.z.object({ type: _v3.z.literal("function"), id: _v3.z.string() }),
1599
+ _v3.z.object({ type: _v3.z.literal("global"), name: _v3.z.string() })
643
1600
  ]);
644
- var PromptDataNullish = _zod.z.union([
645
- _zod.z.object({
1601
+ var PromptDataNullish = _v3.z.union([
1602
+ _v3.z.object({
646
1603
  prompt: PromptBlockDataNullish,
647
1604
  options: PromptOptionsNullish,
648
1605
  parser: PromptParserNullish,
649
- tool_functions: _zod.z.union([_zod.z.array(SavedFunctionId), _zod.z.null()]),
650
- origin: _zod.z.union([
651
- _zod.z.object({
652
- prompt_id: _zod.z.string(),
653
- project_id: _zod.z.string(),
654
- prompt_version: _zod.z.string()
1606
+ tool_functions: _v3.z.union([_v3.z.array(SavedFunctionId), _v3.z.null()]),
1607
+ origin: _v3.z.union([
1608
+ _v3.z.object({
1609
+ prompt_id: _v3.z.string(),
1610
+ project_id: _v3.z.string(),
1611
+ prompt_version: _v3.z.string()
655
1612
  }).partial(),
656
- _zod.z.null()
1613
+ _v3.z.null()
657
1614
  ])
658
1615
  }).partial(),
659
- _zod.z.null()
1616
+ _v3.z.null()
660
1617
  ]);
661
- var FunctionTypeEnumNullish = _zod.z.union([
662
- _zod.z.enum(["llm", "scorer", "task", "tool"]),
663
- _zod.z.null()
1618
+ var FunctionTypeEnumNullish = _v3.z.union([
1619
+ _v3.z.enum(["llm", "scorer", "task", "tool"]),
1620
+ _v3.z.null()
664
1621
  ]);
665
- var FunctionIdRef = _zod.z.object({}).partial().passthrough();
666
- var PromptBlockData = _zod.z.union([
667
- _zod.z.object({ type: _zod.z.literal("completion"), content: _zod.z.string() }),
668
- _zod.z.object({
669
- type: _zod.z.literal("chat"),
670
- messages: _zod.z.array(ChatCompletionMessageParam),
671
- tools: _zod.z.string().optional()
1622
+ var FunctionIdRef = _v3.z.object({}).partial().passthrough();
1623
+ var PromptBlockData = _v3.z.union([
1624
+ _v3.z.object({ type: _v3.z.literal("completion"), content: _v3.z.string() }),
1625
+ _v3.z.object({
1626
+ type: _v3.z.literal("chat"),
1627
+ messages: _v3.z.array(ChatCompletionMessageParam),
1628
+ tools: _v3.z.string().optional()
672
1629
  })
673
1630
  ]);
674
- var GraphNode = _zod.z.union([
675
- _zod.z.object({
676
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
677
- position: _zod.z.union([_zod.z.object({ x: _zod.z.number(), y: _zod.z.number() }), _zod.z.null()]).optional(),
678
- type: _zod.z.literal("function"),
1631
+ var GraphNode = _v3.z.union([
1632
+ _v3.z.object({
1633
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1634
+ position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
1635
+ type: _v3.z.literal("function"),
679
1636
  function: FunctionIdRef
680
1637
  }),
681
- _zod.z.object({
682
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
683
- position: _zod.z.union([_zod.z.object({ x: _zod.z.number(), y: _zod.z.number() }), _zod.z.null()]).optional(),
684
- type: _zod.z.literal("input")
1638
+ _v3.z.object({
1639
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1640
+ position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
1641
+ type: _v3.z.literal("input")
685
1642
  }),
686
- _zod.z.object({
687
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
688
- position: _zod.z.union([_zod.z.object({ x: _zod.z.number(), y: _zod.z.number() }), _zod.z.null()]).optional(),
689
- type: _zod.z.literal("output")
1643
+ _v3.z.object({
1644
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1645
+ position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
1646
+ type: _v3.z.literal("output")
690
1647
  }),
691
- _zod.z.object({
692
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
693
- position: _zod.z.union([_zod.z.object({ x: _zod.z.number(), y: _zod.z.number() }), _zod.z.null()]).optional(),
694
- type: _zod.z.literal("literal"),
695
- value: _zod.z.unknown().optional()
1648
+ _v3.z.object({
1649
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1650
+ position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
1651
+ type: _v3.z.literal("literal"),
1652
+ value: _v3.z.unknown().optional()
696
1653
  }),
697
- _zod.z.object({
698
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
699
- position: _zod.z.union([_zod.z.object({ x: _zod.z.number(), y: _zod.z.number() }), _zod.z.null()]).optional(),
700
- type: _zod.z.literal("btql"),
701
- expr: _zod.z.string()
1654
+ _v3.z.object({
1655
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1656
+ position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
1657
+ type: _v3.z.literal("btql"),
1658
+ expr: _v3.z.string()
702
1659
  }),
703
- _zod.z.object({
704
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
705
- position: _zod.z.union([_zod.z.object({ x: _zod.z.number(), y: _zod.z.number() }), _zod.z.null()]).optional(),
706
- type: _zod.z.literal("gate"),
707
- condition: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1660
+ _v3.z.object({
1661
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1662
+ position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
1663
+ type: _v3.z.literal("gate"),
1664
+ condition: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
708
1665
  }),
709
- _zod.z.object({
710
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
711
- position: _zod.z.union([_zod.z.object({ x: _zod.z.number(), y: _zod.z.number() }), _zod.z.null()]).optional(),
712
- type: _zod.z.literal("aggregator")
1666
+ _v3.z.object({
1667
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1668
+ position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
1669
+ type: _v3.z.literal("aggregator")
713
1670
  }),
714
- _zod.z.object({
715
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
716
- position: _zod.z.union([_zod.z.object({ x: _zod.z.number(), y: _zod.z.number() }), _zod.z.null()]).optional(),
717
- type: _zod.z.literal("prompt_template"),
1671
+ _v3.z.object({
1672
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1673
+ position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
1674
+ type: _v3.z.literal("prompt_template"),
718
1675
  prompt: PromptBlockData
719
1676
  })
720
1677
  ]);
721
- var GraphEdge = _zod.z.object({
722
- source: _zod.z.object({ node: _zod.z.string().max(1024), variable: _zod.z.string() }),
723
- target: _zod.z.object({ node: _zod.z.string().max(1024), variable: _zod.z.string() }),
724
- purpose: _zod.z.enum(["control", "data", "messages"])
1678
+ var GraphEdge = _v3.z.object({
1679
+ source: _v3.z.object({ node: _v3.z.string().max(1024), variable: _v3.z.string() }),
1680
+ target: _v3.z.object({ node: _v3.z.string().max(1024), variable: _v3.z.string() }),
1681
+ purpose: _v3.z.enum(["control", "data", "messages"])
725
1682
  });
726
- var GraphData = _zod.z.object({
727
- type: _zod.z.literal("graph"),
728
- nodes: _zod.z.record(GraphNode),
729
- edges: _zod.z.record(GraphEdge)
1683
+ var GraphData = _v3.z.object({
1684
+ type: _v3.z.literal("graph"),
1685
+ nodes: _v3.z.record(GraphNode),
1686
+ edges: _v3.z.record(GraphEdge)
730
1687
  });
731
- var FunctionData = _zod.z.union([
732
- _zod.z.object({ type: _zod.z.literal("prompt") }),
733
- _zod.z.object({
734
- type: _zod.z.literal("code"),
735
- data: _zod.z.union([
736
- _zod.z.object({ type: _zod.z.literal("bundle") }).and(CodeBundle),
737
- _zod.z.object({
738
- type: _zod.z.literal("inline"),
739
- runtime_context: _zod.z.object({
740
- runtime: _zod.z.enum(["node", "python"]),
741
- version: _zod.z.string()
1688
+ var FunctionData = _v3.z.union([
1689
+ _v3.z.object({ type: _v3.z.literal("prompt") }),
1690
+ _v3.z.object({
1691
+ type: _v3.z.literal("code"),
1692
+ data: _v3.z.union([
1693
+ _v3.z.object({ type: _v3.z.literal("bundle") }).and(CodeBundle),
1694
+ _v3.z.object({
1695
+ type: _v3.z.literal("inline"),
1696
+ runtime_context: _v3.z.object({
1697
+ runtime: _v3.z.enum(["node", "python"]),
1698
+ version: _v3.z.string()
742
1699
  }),
743
- code: _zod.z.string()
1700
+ code: _v3.z.string()
744
1701
  })
745
1702
  ])
746
1703
  }),
747
1704
  GraphData,
748
- _zod.z.object({
749
- type: _zod.z.literal("remote_eval"),
750
- endpoint: _zod.z.string(),
751
- eval_name: _zod.z.string(),
752
- parameters: _zod.z.object({}).partial().passthrough()
1705
+ _v3.z.object({
1706
+ type: _v3.z.literal("remote_eval"),
1707
+ endpoint: _v3.z.string(),
1708
+ eval_name: _v3.z.string(),
1709
+ parameters: _v3.z.object({}).partial().passthrough()
753
1710
  }),
754
- _zod.z.object({ type: _zod.z.literal("global"), name: _zod.z.string() })
1711
+ _v3.z.object({ type: _v3.z.literal("global"), name: _v3.z.string() })
755
1712
  ]);
756
- var Function = _zod.z.object({
757
- id: _zod.z.string().uuid(),
758
- _xact_id: _zod.z.string(),
759
- project_id: _zod.z.string().uuid(),
760
- log_id: _zod.z.literal("p"),
761
- org_id: _zod.z.string().uuid(),
762
- name: _zod.z.string(),
763
- slug: _zod.z.string(),
764
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
765
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1713
+ var Function = _v3.z.object({
1714
+ id: _v3.z.string().uuid(),
1715
+ _xact_id: _v3.z.string(),
1716
+ project_id: _v3.z.string().uuid(),
1717
+ log_id: _v3.z.literal("p"),
1718
+ org_id: _v3.z.string().uuid(),
1719
+ name: _v3.z.string(),
1720
+ slug: _v3.z.string(),
1721
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1722
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
766
1723
  prompt_data: PromptDataNullish.optional(),
767
- tags: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional(),
768
- metadata: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.null()]).optional(),
1724
+ tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
1725
+ metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional(),
769
1726
  function_type: FunctionTypeEnumNullish.optional(),
770
1727
  function_data: FunctionData,
771
- origin: _zod.z.union([
772
- _zod.z.object({
773
- object_type: AclObjectType.and(_zod.z.string()),
774
- object_id: _zod.z.string().uuid(),
775
- internal: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional()
1728
+ origin: _v3.z.union([
1729
+ _v3.z.object({
1730
+ object_type: AclObjectType.and(_v3.z.string()),
1731
+ object_id: _v3.z.string().uuid(),
1732
+ internal: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
776
1733
  }),
777
- _zod.z.null()
1734
+ _v3.z.null()
778
1735
  ]).optional(),
779
- function_schema: _zod.z.union([
780
- _zod.z.object({ parameters: _zod.z.unknown(), returns: _zod.z.unknown() }).partial(),
781
- _zod.z.null()
1736
+ function_schema: _v3.z.union([
1737
+ _v3.z.object({ parameters: _v3.z.unknown(), returns: _v3.z.unknown() }).partial(),
1738
+ _v3.z.null()
782
1739
  ]).optional()
783
1740
  });
784
- var FunctionFormat = _zod.z.enum(["llm", "code", "global", "graph"]);
785
- var PromptData = _zod.z.object({
1741
+ var FunctionFormat = _v3.z.enum(["llm", "code", "global", "graph"]);
1742
+ var PromptData = _v3.z.object({
786
1743
  prompt: PromptBlockDataNullish,
787
1744
  options: PromptOptionsNullish,
788
1745
  parser: PromptParserNullish,
789
- tool_functions: _zod.z.union([_zod.z.array(SavedFunctionId), _zod.z.null()]),
790
- origin: _zod.z.union([
791
- _zod.z.object({
792
- prompt_id: _zod.z.string(),
793
- project_id: _zod.z.string(),
794
- prompt_version: _zod.z.string()
1746
+ tool_functions: _v3.z.union([_v3.z.array(SavedFunctionId), _v3.z.null()]),
1747
+ origin: _v3.z.union([
1748
+ _v3.z.object({
1749
+ prompt_id: _v3.z.string(),
1750
+ project_id: _v3.z.string(),
1751
+ prompt_version: _v3.z.string()
795
1752
  }).partial(),
796
- _zod.z.null()
1753
+ _v3.z.null()
797
1754
  ])
798
1755
  }).partial();
799
- var FunctionTypeEnum = _zod.z.enum(["llm", "scorer", "task", "tool"]);
800
- var FunctionId = _zod.z.union([
801
- _zod.z.object({ function_id: _zod.z.string(), version: _zod.z.string().optional() }),
802
- _zod.z.object({
803
- project_name: _zod.z.string(),
804
- slug: _zod.z.string(),
805
- version: _zod.z.string().optional()
1756
+ var FunctionTypeEnum = _v3.z.enum(["llm", "scorer", "task", "tool"]);
1757
+ var FunctionId = _v3.z.union([
1758
+ _v3.z.object({ function_id: _v3.z.string(), version: _v3.z.string().optional() }),
1759
+ _v3.z.object({
1760
+ project_name: _v3.z.string(),
1761
+ slug: _v3.z.string(),
1762
+ version: _v3.z.string().optional()
806
1763
  }),
807
- _zod.z.object({ global_function: _zod.z.string() }),
808
- _zod.z.object({
809
- prompt_session_id: _zod.z.string(),
810
- prompt_session_function_id: _zod.z.string(),
811
- version: _zod.z.string().optional()
1764
+ _v3.z.object({ global_function: _v3.z.string() }),
1765
+ _v3.z.object({
1766
+ prompt_session_id: _v3.z.string(),
1767
+ prompt_session_function_id: _v3.z.string(),
1768
+ version: _v3.z.string().optional()
812
1769
  }),
813
- _zod.z.object({
814
- inline_context: _zod.z.object({
815
- runtime: _zod.z.enum(["node", "python"]),
816
- version: _zod.z.string()
1770
+ _v3.z.object({
1771
+ inline_context: _v3.z.object({
1772
+ runtime: _v3.z.enum(["node", "python"]),
1773
+ version: _v3.z.string()
817
1774
  }),
818
- code: _zod.z.string(),
819
- name: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1775
+ code: _v3.z.string(),
1776
+ name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
820
1777
  }),
821
- _zod.z.object({
1778
+ _v3.z.object({
822
1779
  inline_prompt: PromptData.optional(),
823
- inline_function: _zod.z.object({}).partial().passthrough(),
1780
+ inline_function: _v3.z.object({}).partial().passthrough(),
824
1781
  function_type: FunctionTypeEnum.optional(),
825
- name: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1782
+ name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
826
1783
  }),
827
- _zod.z.object({
1784
+ _v3.z.object({
828
1785
  inline_prompt: PromptData,
829
1786
  function_type: FunctionTypeEnum.optional(),
830
- name: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1787
+ name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
831
1788
  })
832
1789
  ]);
833
- var FunctionObjectType = _zod.z.enum([
1790
+ var FunctionObjectType = _v3.z.enum([
834
1791
  "prompt",
835
1792
  "tool",
836
1793
  "scorer",
837
1794
  "task",
838
1795
  "agent"
839
1796
  ]);
840
- var FunctionOutputType = _zod.z.enum(["completion", "score", "any"]);
841
- var GitMetadataSettings = _zod.z.object({
842
- collect: _zod.z.enum(["all", "none", "some"]),
843
- fields: _zod.z.array(
844
- _zod.z.enum([
1797
+ var FunctionOutputType = _v3.z.enum(["completion", "score", "any"]);
1798
+ var GitMetadataSettings = _v3.z.object({
1799
+ collect: _v3.z.enum(["all", "none", "some"]),
1800
+ fields: _v3.z.array(
1801
+ _v3.z.enum([
845
1802
  "commit",
846
1803
  "branch",
847
1804
  "tag",
@@ -854,49 +1811,49 @@ var GitMetadataSettings = _zod.z.object({
854
1811
  ])
855
1812
  ).optional()
856
1813
  });
857
- var Group = _zod.z.object({
858
- id: _zod.z.string().uuid(),
859
- org_id: _zod.z.string().uuid(),
860
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
861
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
862
- name: _zod.z.string(),
863
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
864
- deleted_at: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
865
- member_users: _zod.z.union([_zod.z.array(_zod.z.string().uuid()), _zod.z.null()]).optional(),
866
- member_groups: _zod.z.union([_zod.z.array(_zod.z.string().uuid()), _zod.z.null()]).optional()
1814
+ var Group = _v3.z.object({
1815
+ id: _v3.z.string().uuid(),
1816
+ org_id: _v3.z.string().uuid(),
1817
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1818
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1819
+ name: _v3.z.string(),
1820
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1821
+ deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1822
+ member_users: _v3.z.union([_v3.z.array(_v3.z.string().uuid()), _v3.z.null()]).optional(),
1823
+ member_groups: _v3.z.union([_v3.z.array(_v3.z.string().uuid()), _v3.z.null()]).optional()
867
1824
  });
868
- var IfExists = _zod.z.enum(["error", "ignore", "replace"]);
869
- var InvokeParent = _zod.z.union([
870
- _zod.z.object({
871
- object_type: _zod.z.enum(["project_logs", "experiment", "playground_logs"]),
872
- object_id: _zod.z.string(),
873
- row_ids: _zod.z.union([
874
- _zod.z.object({
875
- id: _zod.z.string(),
876
- span_id: _zod.z.string(),
877
- root_span_id: _zod.z.string()
1825
+ var IfExists = _v3.z.enum(["error", "ignore", "replace"]);
1826
+ var InvokeParent = _v3.z.union([
1827
+ _v3.z.object({
1828
+ object_type: _v3.z.enum(["project_logs", "experiment", "playground_logs"]),
1829
+ object_id: _v3.z.string(),
1830
+ row_ids: _v3.z.union([
1831
+ _v3.z.object({
1832
+ id: _v3.z.string(),
1833
+ span_id: _v3.z.string(),
1834
+ root_span_id: _v3.z.string()
878
1835
  }),
879
- _zod.z.null()
1836
+ _v3.z.null()
880
1837
  ]).optional(),
881
- propagated_event: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.null()]).optional()
1838
+ propagated_event: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional()
882
1839
  }),
883
- _zod.z.string()
1840
+ _v3.z.string()
884
1841
  ]);
885
- var StreamingMode = _zod.z.union([_zod.z.enum(["auto", "parallel"]), _zod.z.null()]);
1842
+ var StreamingMode = _v3.z.union([_v3.z.enum(["auto", "parallel"]), _v3.z.null()]);
886
1843
  var InvokeFunction = FunctionId.and(
887
- _zod.z.object({
888
- input: _zod.z.unknown(),
889
- expected: _zod.z.unknown(),
890
- metadata: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.null()]),
891
- tags: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]),
892
- messages: _zod.z.array(ChatCompletionMessageParam),
1844
+ _v3.z.object({
1845
+ input: _v3.z.unknown(),
1846
+ expected: _v3.z.unknown(),
1847
+ metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]),
1848
+ tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]),
1849
+ messages: _v3.z.array(ChatCompletionMessageParam),
893
1850
  parent: InvokeParent,
894
- stream: _zod.z.union([_zod.z.boolean(), _zod.z.null()]),
1851
+ stream: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
895
1852
  mode: StreamingMode,
896
- strict: _zod.z.union([_zod.z.boolean(), _zod.z.null()])
1853
+ strict: _v3.z.union([_v3.z.boolean(), _v3.z.null()])
897
1854
  }).partial()
898
1855
  );
899
- var MessageRole = _zod.z.enum([
1856
+ var MessageRole = _v3.z.enum([
900
1857
  "system",
901
1858
  "user",
902
1859
  "assistant",
@@ -905,8 +1862,8 @@ var MessageRole = _zod.z.enum([
905
1862
  "model",
906
1863
  "developer"
907
1864
  ]);
908
- var ObjectReference = _zod.z.object({
909
- object_type: _zod.z.enum([
1865
+ var ObjectReference = _v3.z.object({
1866
+ object_type: _v3.z.enum([
910
1867
  "project_logs",
911
1868
  "experiment",
912
1869
  "dataset",
@@ -914,146 +1871,146 @@ var ObjectReference = _zod.z.object({
914
1871
  "function",
915
1872
  "prompt_session"
916
1873
  ]),
917
- object_id: _zod.z.string().uuid(),
918
- id: _zod.z.string(),
919
- _xact_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
920
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1874
+ object_id: _v3.z.string().uuid(),
1875
+ id: _v3.z.string(),
1876
+ _xact_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1877
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
921
1878
  });
922
- var OnlineScoreConfig = _zod.z.union([
923
- _zod.z.object({
924
- sampling_rate: _zod.z.number().gte(0).lte(1),
925
- scorers: _zod.z.array(SavedFunctionId),
926
- btql_filter: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
927
- apply_to_root_span: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional(),
928
- apply_to_span_names: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional(),
929
- skip_logging: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional()
1879
+ var OnlineScoreConfig = _v3.z.union([
1880
+ _v3.z.object({
1881
+ sampling_rate: _v3.z.number().gte(0).lte(1),
1882
+ scorers: _v3.z.array(SavedFunctionId),
1883
+ btql_filter: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1884
+ apply_to_root_span: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
1885
+ apply_to_span_names: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
1886
+ skip_logging: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
930
1887
  }),
931
- _zod.z.null()
1888
+ _v3.z.null()
932
1889
  ]);
933
- var Organization = _zod.z.object({
934
- id: _zod.z.string().uuid(),
935
- name: _zod.z.string(),
936
- api_url: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
937
- is_universal_api: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional(),
938
- proxy_url: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
939
- realtime_url: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
940
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1890
+ var Organization = _v3.z.object({
1891
+ id: _v3.z.string().uuid(),
1892
+ name: _v3.z.string(),
1893
+ api_url: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1894
+ is_universal_api: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
1895
+ proxy_url: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1896
+ realtime_url: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1897
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
941
1898
  });
942
- var ProjectSettings = _zod.z.union([
943
- _zod.z.object({
944
- comparison_key: _zod.z.union([_zod.z.string(), _zod.z.null()]),
945
- baseline_experiment_id: _zod.z.union([_zod.z.string(), _zod.z.null()]),
946
- spanFieldOrder: _zod.z.union([
947
- _zod.z.array(
948
- _zod.z.object({
949
- object_type: _zod.z.string(),
950
- column_id: _zod.z.string(),
951
- position: _zod.z.string(),
952
- layout: _zod.z.union([_zod.z.literal("full"), _zod.z.literal("two_column"), _zod.z.null()]).optional()
1899
+ var ProjectSettings = _v3.z.union([
1900
+ _v3.z.object({
1901
+ comparison_key: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1902
+ baseline_experiment_id: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1903
+ spanFieldOrder: _v3.z.union([
1904
+ _v3.z.array(
1905
+ _v3.z.object({
1906
+ object_type: _v3.z.string(),
1907
+ column_id: _v3.z.string(),
1908
+ position: _v3.z.string(),
1909
+ layout: _v3.z.union([_v3.z.literal("full"), _v3.z.literal("two_column"), _v3.z.null()]).optional()
953
1910
  })
954
1911
  ),
955
- _zod.z.null()
1912
+ _v3.z.null()
956
1913
  ]),
957
- remote_eval_sources: _zod.z.union([
958
- _zod.z.array(
959
- _zod.z.object({
960
- url: _zod.z.string(),
961
- name: _zod.z.string(),
962
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
1914
+ remote_eval_sources: _v3.z.union([
1915
+ _v3.z.array(
1916
+ _v3.z.object({
1917
+ url: _v3.z.string(),
1918
+ name: _v3.z.string(),
1919
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
963
1920
  })
964
1921
  ),
965
- _zod.z.null()
1922
+ _v3.z.null()
966
1923
  ])
967
1924
  }).partial(),
968
- _zod.z.null()
1925
+ _v3.z.null()
969
1926
  ]);
970
- var Project = _zod.z.object({
971
- id: _zod.z.string().uuid(),
972
- org_id: _zod.z.string().uuid(),
973
- name: _zod.z.string(),
974
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
975
- deleted_at: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
976
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1927
+ var Project = _v3.z.object({
1928
+ id: _v3.z.string().uuid(),
1929
+ org_id: _v3.z.string().uuid(),
1930
+ name: _v3.z.string(),
1931
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1932
+ deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1933
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
977
1934
  settings: ProjectSettings.optional()
978
1935
  });
979
- var RetentionObjectType = _zod.z.enum([
1936
+ var RetentionObjectType = _v3.z.enum([
980
1937
  "project_logs",
981
1938
  "experiment",
982
1939
  "dataset"
983
1940
  ]);
984
- var ProjectAutomation = _zod.z.object({
985
- id: _zod.z.string().uuid(),
986
- project_id: _zod.z.string().uuid(),
987
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
988
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
989
- name: _zod.z.string(),
990
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
991
- config: _zod.z.union([
992
- _zod.z.object({
993
- event_type: _zod.z.literal("logs"),
994
- btql_filter: _zod.z.string(),
995
- interval_seconds: _zod.z.number().gte(1).lte(2592e3),
996
- action: _zod.z.object({ type: _zod.z.literal("webhook"), url: _zod.z.string() })
1941
+ var ProjectAutomation = _v3.z.object({
1942
+ id: _v3.z.string().uuid(),
1943
+ project_id: _v3.z.string().uuid(),
1944
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1945
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1946
+ name: _v3.z.string(),
1947
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1948
+ config: _v3.z.union([
1949
+ _v3.z.object({
1950
+ event_type: _v3.z.literal("logs"),
1951
+ btql_filter: _v3.z.string(),
1952
+ interval_seconds: _v3.z.number().gte(1).lte(2592e3),
1953
+ action: _v3.z.object({ type: _v3.z.literal("webhook"), url: _v3.z.string() })
997
1954
  }),
998
- _zod.z.object({
999
- event_type: _zod.z.literal("btql_export"),
1000
- export_definition: _zod.z.union([
1001
- _zod.z.object({ type: _zod.z.literal("log_traces") }),
1002
- _zod.z.object({ type: _zod.z.literal("log_spans") }),
1003
- _zod.z.object({ type: _zod.z.literal("btql_query"), btql_query: _zod.z.string() })
1955
+ _v3.z.object({
1956
+ event_type: _v3.z.literal("btql_export"),
1957
+ export_definition: _v3.z.union([
1958
+ _v3.z.object({ type: _v3.z.literal("log_traces") }),
1959
+ _v3.z.object({ type: _v3.z.literal("log_spans") }),
1960
+ _v3.z.object({ type: _v3.z.literal("btql_query"), btql_query: _v3.z.string() })
1004
1961
  ]),
1005
- export_path: _zod.z.string(),
1006
- format: _zod.z.enum(["jsonl", "parquet"]),
1007
- interval_seconds: _zod.z.number().gte(1).lte(2592e3),
1008
- credentials: _zod.z.object({
1009
- type: _zod.z.literal("aws_iam"),
1010
- role_arn: _zod.z.string(),
1011
- external_id: _zod.z.string()
1962
+ export_path: _v3.z.string(),
1963
+ format: _v3.z.enum(["jsonl", "parquet"]),
1964
+ interval_seconds: _v3.z.number().gte(1).lte(2592e3),
1965
+ credentials: _v3.z.object({
1966
+ type: _v3.z.literal("aws_iam"),
1967
+ role_arn: _v3.z.string(),
1968
+ external_id: _v3.z.string()
1012
1969
  }),
1013
- batch_size: _zod.z.union([_zod.z.number(), _zod.z.null()]).optional()
1970
+ batch_size: _v3.z.union([_v3.z.number(), _v3.z.null()]).optional()
1014
1971
  }),
1015
- _zod.z.object({
1016
- event_type: _zod.z.literal("retention"),
1972
+ _v3.z.object({
1973
+ event_type: _v3.z.literal("retention"),
1017
1974
  object_type: RetentionObjectType,
1018
- retention_days: _zod.z.number().gte(0)
1975
+ retention_days: _v3.z.number().gte(0)
1019
1976
  })
1020
1977
  ])
1021
1978
  });
1022
- var ProjectLogsEvent = _zod.z.object({
1023
- id: _zod.z.string(),
1024
- _xact_id: _zod.z.string(),
1025
- _pagination_key: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1026
- created: _zod.z.string().datetime({ offset: true }),
1027
- org_id: _zod.z.string().uuid(),
1028
- project_id: _zod.z.string().uuid(),
1029
- log_id: _zod.z.literal("g"),
1030
- input: _zod.z.unknown().optional(),
1031
- output: _zod.z.unknown().optional(),
1032
- expected: _zod.z.unknown().optional(),
1033
- error: _zod.z.unknown().optional(),
1034
- scores: _zod.z.union([_zod.z.record(_zod.z.union([_zod.z.number(), _zod.z.null()])), _zod.z.null()]).optional(),
1035
- metadata: _zod.z.union([
1036
- _zod.z.object({ model: _zod.z.union([_zod.z.string(), _zod.z.null()]) }).partial().passthrough(),
1037
- _zod.z.null()
1979
+ var ProjectLogsEvent = _v3.z.object({
1980
+ id: _v3.z.string(),
1981
+ _xact_id: _v3.z.string(),
1982
+ _pagination_key: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1983
+ created: _v3.z.string().datetime({ offset: true }),
1984
+ org_id: _v3.z.string().uuid(),
1985
+ project_id: _v3.z.string().uuid(),
1986
+ log_id: _v3.z.literal("g"),
1987
+ input: _v3.z.unknown().optional(),
1988
+ output: _v3.z.unknown().optional(),
1989
+ expected: _v3.z.unknown().optional(),
1990
+ error: _v3.z.unknown().optional(),
1991
+ scores: _v3.z.union([_v3.z.record(_v3.z.union([_v3.z.number(), _v3.z.null()])), _v3.z.null()]).optional(),
1992
+ metadata: _v3.z.union([
1993
+ _v3.z.object({ model: _v3.z.union([_v3.z.string(), _v3.z.null()]) }).partial().passthrough(),
1994
+ _v3.z.null()
1038
1995
  ]).optional(),
1039
- tags: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional(),
1040
- metrics: _zod.z.union([_zod.z.record(_zod.z.number()), _zod.z.null()]).optional(),
1041
- context: _zod.z.union([
1042
- _zod.z.object({
1043
- caller_functionname: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1044
- caller_filename: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1045
- caller_lineno: _zod.z.union([_zod.z.number(), _zod.z.null()])
1996
+ tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
1997
+ metrics: _v3.z.union([_v3.z.record(_v3.z.number()), _v3.z.null()]).optional(),
1998
+ context: _v3.z.union([
1999
+ _v3.z.object({
2000
+ caller_functionname: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2001
+ caller_filename: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2002
+ caller_lineno: _v3.z.union([_v3.z.number(), _v3.z.null()])
1046
2003
  }).partial().passthrough(),
1047
- _zod.z.null()
2004
+ _v3.z.null()
1048
2005
  ]).optional(),
1049
- span_id: _zod.z.string(),
1050
- span_parents: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional(),
1051
- root_span_id: _zod.z.string(),
1052
- is_root: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional(),
2006
+ span_id: _v3.z.string(),
2007
+ span_parents: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
2008
+ root_span_id: _v3.z.string(),
2009
+ is_root: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
1053
2010
  span_attributes: SpanAttributes.optional(),
1054
2011
  origin: ObjectReferenceNullish.optional()
1055
2012
  });
1056
- var ProjectScoreType = _zod.z.enum([
2013
+ var ProjectScoreType = _v3.z.enum([
1057
2014
  "slider",
1058
2015
  "categorical",
1059
2016
  "weighted",
@@ -1062,172 +2019,172 @@ var ProjectScoreType = _zod.z.enum([
1062
2019
  "online",
1063
2020
  "free-form"
1064
2021
  ]);
1065
- var ProjectScoreCategory = _zod.z.object({
1066
- name: _zod.z.string(),
1067
- value: _zod.z.number()
2022
+ var ProjectScoreCategory = _v3.z.object({
2023
+ name: _v3.z.string(),
2024
+ value: _v3.z.number()
1068
2025
  });
1069
- var ProjectScoreCategories = _zod.z.union([
1070
- _zod.z.array(ProjectScoreCategory),
1071
- _zod.z.record(_zod.z.number()),
1072
- _zod.z.array(_zod.z.string()),
1073
- _zod.z.null()
2026
+ var ProjectScoreCategories = _v3.z.union([
2027
+ _v3.z.array(ProjectScoreCategory),
2028
+ _v3.z.record(_v3.z.number()),
2029
+ _v3.z.array(_v3.z.string()),
2030
+ _v3.z.null()
1074
2031
  ]);
1075
- var ProjectScoreConfig = _zod.z.union([
1076
- _zod.z.object({
1077
- multi_select: _zod.z.union([_zod.z.boolean(), _zod.z.null()]),
1078
- destination: _zod.z.union([_zod.z.string(), _zod.z.null()]),
2032
+ var ProjectScoreConfig = _v3.z.union([
2033
+ _v3.z.object({
2034
+ multi_select: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
2035
+ destination: _v3.z.union([_v3.z.string(), _v3.z.null()]),
1079
2036
  online: OnlineScoreConfig
1080
2037
  }).partial(),
1081
- _zod.z.null()
2038
+ _v3.z.null()
1082
2039
  ]);
1083
- var ProjectScore = _zod.z.object({
1084
- id: _zod.z.string().uuid(),
1085
- project_id: _zod.z.string().uuid(),
1086
- user_id: _zod.z.string().uuid(),
1087
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1088
- name: _zod.z.string(),
1089
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
2040
+ var ProjectScore = _v3.z.object({
2041
+ id: _v3.z.string().uuid(),
2042
+ project_id: _v3.z.string().uuid(),
2043
+ user_id: _v3.z.string().uuid(),
2044
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2045
+ name: _v3.z.string(),
2046
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1090
2047
  score_type: ProjectScoreType,
1091
2048
  categories: ProjectScoreCategories.optional(),
1092
2049
  config: ProjectScoreConfig.optional(),
1093
- position: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
2050
+ position: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
1094
2051
  });
1095
- var ProjectTag = _zod.z.object({
1096
- id: _zod.z.string().uuid(),
1097
- project_id: _zod.z.string().uuid(),
1098
- user_id: _zod.z.string().uuid(),
1099
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1100
- name: _zod.z.string(),
1101
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1102
- color: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1103
- position: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
2052
+ var ProjectTag = _v3.z.object({
2053
+ id: _v3.z.string().uuid(),
2054
+ project_id: _v3.z.string().uuid(),
2055
+ user_id: _v3.z.string().uuid(),
2056
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2057
+ name: _v3.z.string(),
2058
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2059
+ color: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2060
+ position: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
1104
2061
  });
1105
- var Prompt = _zod.z.object({
1106
- id: _zod.z.string().uuid(),
1107
- _xact_id: _zod.z.string(),
1108
- project_id: _zod.z.string().uuid(),
1109
- log_id: _zod.z.literal("p"),
1110
- org_id: _zod.z.string().uuid(),
1111
- name: _zod.z.string(),
1112
- slug: _zod.z.string(),
1113
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1114
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
2062
+ var Prompt = _v3.z.object({
2063
+ id: _v3.z.string().uuid(),
2064
+ _xact_id: _v3.z.string(),
2065
+ project_id: _v3.z.string().uuid(),
2066
+ log_id: _v3.z.literal("p"),
2067
+ org_id: _v3.z.string().uuid(),
2068
+ name: _v3.z.string(),
2069
+ slug: _v3.z.string(),
2070
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2071
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1115
2072
  prompt_data: PromptDataNullish.optional(),
1116
- tags: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional(),
1117
- metadata: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.null()]).optional(),
2073
+ tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
2074
+ metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional(),
1118
2075
  function_type: FunctionTypeEnumNullish.optional()
1119
2076
  });
1120
- var PromptOptions = _zod.z.object({ model: _zod.z.string(), params: ModelParams, position: _zod.z.string() }).partial();
1121
- var PromptSessionEvent = _zod.z.object({
1122
- id: _zod.z.string(),
1123
- _xact_id: _zod.z.string(),
1124
- created: _zod.z.string().datetime({ offset: true }),
1125
- _pagination_key: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1126
- project_id: _zod.z.string().uuid(),
1127
- prompt_session_id: _zod.z.string().uuid(),
1128
- prompt_session_data: _zod.z.unknown().optional(),
1129
- prompt_data: _zod.z.unknown().optional(),
1130
- function_data: _zod.z.unknown().optional(),
2077
+ var PromptOptions = _v3.z.object({ model: _v3.z.string(), params: ModelParams, position: _v3.z.string() }).partial();
2078
+ var PromptSessionEvent = _v3.z.object({
2079
+ id: _v3.z.string(),
2080
+ _xact_id: _v3.z.string(),
2081
+ created: _v3.z.string().datetime({ offset: true }),
2082
+ _pagination_key: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2083
+ project_id: _v3.z.string().uuid(),
2084
+ prompt_session_id: _v3.z.string().uuid(),
2085
+ prompt_session_data: _v3.z.unknown().optional(),
2086
+ prompt_data: _v3.z.unknown().optional(),
2087
+ function_data: _v3.z.unknown().optional(),
1131
2088
  function_type: FunctionTypeEnumNullish.optional(),
1132
- object_data: _zod.z.unknown().optional(),
1133
- completion: _zod.z.unknown().optional(),
1134
- tags: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]).optional()
2089
+ object_data: _v3.z.unknown().optional(),
2090
+ completion: _v3.z.unknown().optional(),
2091
+ tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional()
1135
2092
  });
1136
- var ResponseFormat = _zod.z.union([
1137
- _zod.z.object({ type: _zod.z.literal("json_object") }),
1138
- _zod.z.object({
1139
- type: _zod.z.literal("json_schema"),
2093
+ var ResponseFormat = _v3.z.union([
2094
+ _v3.z.object({ type: _v3.z.literal("json_object") }),
2095
+ _v3.z.object({
2096
+ type: _v3.z.literal("json_schema"),
1140
2097
  json_schema: ResponseFormatJsonSchema
1141
2098
  }),
1142
- _zod.z.object({ type: _zod.z.literal("text") })
2099
+ _v3.z.object({ type: _v3.z.literal("text") })
1143
2100
  ]);
1144
- var Role = _zod.z.object({
1145
- id: _zod.z.string().uuid(),
1146
- org_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1147
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1148
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1149
- name: _zod.z.string(),
1150
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1151
- deleted_at: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1152
- member_permissions: _zod.z.union([
1153
- _zod.z.array(
1154
- _zod.z.object({
2101
+ var Role = _v3.z.object({
2102
+ id: _v3.z.string().uuid(),
2103
+ org_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2104
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2105
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2106
+ name: _v3.z.string(),
2107
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2108
+ deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2109
+ member_permissions: _v3.z.union([
2110
+ _v3.z.array(
2111
+ _v3.z.object({
1155
2112
  permission: Permission,
1156
2113
  restrict_object_type: AclObjectType.optional()
1157
2114
  })
1158
2115
  ),
1159
- _zod.z.null()
2116
+ _v3.z.null()
1160
2117
  ]).optional(),
1161
- member_roles: _zod.z.union([_zod.z.array(_zod.z.string().uuid()), _zod.z.null()]).optional()
2118
+ member_roles: _v3.z.union([_v3.z.array(_v3.z.string().uuid()), _v3.z.null()]).optional()
1162
2119
  });
1163
- var RunEval = _zod.z.object({
1164
- project_id: _zod.z.string(),
1165
- data: _zod.z.union([
1166
- _zod.z.object({
1167
- dataset_id: _zod.z.string(),
1168
- _internal_btql: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.null()]).optional()
2120
+ var RunEval = _v3.z.object({
2121
+ project_id: _v3.z.string(),
2122
+ data: _v3.z.union([
2123
+ _v3.z.object({
2124
+ dataset_id: _v3.z.string(),
2125
+ _internal_btql: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional()
1169
2126
  }),
1170
- _zod.z.object({
1171
- project_name: _zod.z.string(),
1172
- dataset_name: _zod.z.string(),
1173
- _internal_btql: _zod.z.union([_zod.z.object({}).partial().passthrough(), _zod.z.null()]).optional()
2127
+ _v3.z.object({
2128
+ project_name: _v3.z.string(),
2129
+ dataset_name: _v3.z.string(),
2130
+ _internal_btql: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional()
1174
2131
  }),
1175
- _zod.z.object({ data: _zod.z.array(_zod.z.unknown()) })
2132
+ _v3.z.object({ data: _v3.z.array(_v3.z.unknown()) })
1176
2133
  ]),
1177
- task: FunctionId.and(_zod.z.unknown()),
1178
- scores: _zod.z.array(FunctionId),
1179
- experiment_name: _zod.z.string().optional(),
1180
- metadata: _zod.z.object({}).partial().passthrough().optional(),
1181
- parent: InvokeParent.and(_zod.z.unknown()).optional(),
1182
- stream: _zod.z.boolean().optional(),
1183
- trial_count: _zod.z.union([_zod.z.number(), _zod.z.null()]).optional(),
1184
- is_public: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional(),
1185
- timeout: _zod.z.union([_zod.z.number(), _zod.z.null()]).optional(),
1186
- max_concurrency: _zod.z.union([_zod.z.number(), _zod.z.null()]).optional().default(10),
1187
- base_experiment_name: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1188
- base_experiment_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
2134
+ task: FunctionId.and(_v3.z.unknown()),
2135
+ scores: _v3.z.array(FunctionId),
2136
+ experiment_name: _v3.z.string().optional(),
2137
+ metadata: _v3.z.object({}).partial().passthrough().optional(),
2138
+ parent: InvokeParent.and(_v3.z.unknown()).optional(),
2139
+ stream: _v3.z.boolean().optional(),
2140
+ trial_count: _v3.z.union([_v3.z.number(), _v3.z.null()]).optional(),
2141
+ is_public: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
2142
+ timeout: _v3.z.union([_v3.z.number(), _v3.z.null()]).optional(),
2143
+ max_concurrency: _v3.z.union([_v3.z.number(), _v3.z.null()]).optional().default(10),
2144
+ base_experiment_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2145
+ base_experiment_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1189
2146
  git_metadata_settings: GitMetadataSettings.and(
1190
- _zod.z.union([_zod.z.object({}).partial(), _zod.z.null()])
2147
+ _v3.z.union([_v3.z.object({}).partial(), _v3.z.null()])
1191
2148
  ).optional(),
1192
- repo_info: RepoInfo.and(_zod.z.unknown()).optional(),
1193
- strict: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional(),
1194
- stop_token: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1195
- extra_messages: _zod.z.string().optional(),
1196
- tags: _zod.z.array(_zod.z.string()).optional()
2149
+ repo_info: RepoInfo.and(_v3.z.unknown()).optional(),
2150
+ strict: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
2151
+ stop_token: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2152
+ extra_messages: _v3.z.string().optional(),
2153
+ tags: _v3.z.array(_v3.z.string()).optional()
1197
2154
  });
1198
- var ServiceToken = _zod.z.object({
1199
- id: _zod.z.string().uuid(),
1200
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1201
- name: _zod.z.string(),
1202
- preview_name: _zod.z.string(),
1203
- service_account_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1204
- service_account_email: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1205
- service_account_name: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1206
- org_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
2155
+ var ServiceToken = _v3.z.object({
2156
+ id: _v3.z.string().uuid(),
2157
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2158
+ name: _v3.z.string(),
2159
+ preview_name: _v3.z.string(),
2160
+ service_account_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2161
+ service_account_email: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2162
+ service_account_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2163
+ org_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
1207
2164
  });
1208
- var SpanIFrame = _zod.z.object({
1209
- id: _zod.z.string().uuid(),
1210
- project_id: _zod.z.string().uuid(),
1211
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1212
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1213
- deleted_at: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1214
- name: _zod.z.string(),
1215
- description: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1216
- url: _zod.z.string(),
1217
- post_message: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional()
2165
+ var SpanIFrame = _v3.z.object({
2166
+ id: _v3.z.string().uuid(),
2167
+ project_id: _v3.z.string().uuid(),
2168
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2169
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2170
+ deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2171
+ name: _v3.z.string(),
2172
+ description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2173
+ url: _v3.z.string(),
2174
+ post_message: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
1218
2175
  });
1219
- var SSEConsoleEventData = _zod.z.object({
1220
- stream: _zod.z.enum(["stderr", "stdout"]),
1221
- message: _zod.z.string()
2176
+ var SSEConsoleEventData = _v3.z.object({
2177
+ stream: _v3.z.enum(["stderr", "stdout"]),
2178
+ message: _v3.z.string()
1222
2179
  });
1223
- var SSEProgressEventData = _zod.z.object({
1224
- id: _zod.z.string(),
2180
+ var SSEProgressEventData = _v3.z.object({
2181
+ id: _v3.z.string(),
1225
2182
  object_type: FunctionObjectType,
1226
- origin: ObjectReferenceNullish.and(_zod.z.unknown()).optional(),
2183
+ origin: ObjectReferenceNullish.and(_v3.z.unknown()).optional(),
1227
2184
  format: FunctionFormat,
1228
2185
  output_type: FunctionOutputType,
1229
- name: _zod.z.string(),
1230
- event: _zod.z.enum([
2186
+ name: _v3.z.string(),
2187
+ event: _v3.z.enum([
1231
2188
  "reasoning_delta",
1232
2189
  "text_delta",
1233
2190
  "json_delta",
@@ -1237,110 +2194,110 @@ var SSEProgressEventData = _zod.z.object({
1237
2194
  "done",
1238
2195
  "progress"
1239
2196
  ]),
1240
- data: _zod.z.string()
2197
+ data: _v3.z.string()
1241
2198
  });
1242
- var ToolFunctionDefinition = _zod.z.object({
1243
- type: _zod.z.literal("function"),
1244
- function: _zod.z.object({
1245
- name: _zod.z.string(),
1246
- description: _zod.z.string().optional(),
1247
- parameters: _zod.z.object({}).partial().passthrough().optional(),
1248
- strict: _zod.z.union([_zod.z.boolean(), _zod.z.null()]).optional()
2199
+ var ToolFunctionDefinition = _v3.z.object({
2200
+ type: _v3.z.literal("function"),
2201
+ function: _v3.z.object({
2202
+ name: _v3.z.string(),
2203
+ description: _v3.z.string().optional(),
2204
+ parameters: _v3.z.object({}).partial().passthrough().optional(),
2205
+ strict: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
1249
2206
  })
1250
2207
  });
1251
- var User = _zod.z.object({
1252
- id: _zod.z.string().uuid(),
1253
- given_name: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1254
- family_name: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1255
- email: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1256
- avatar_url: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1257
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
2208
+ var User = _v3.z.object({
2209
+ id: _v3.z.string().uuid(),
2210
+ given_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2211
+ family_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2212
+ email: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2213
+ avatar_url: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2214
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
1258
2215
  });
1259
- var ViewDataSearch = _zod.z.union([
1260
- _zod.z.object({
1261
- filter: _zod.z.union([_zod.z.array(_zod.z.unknown()), _zod.z.null()]),
1262
- tag: _zod.z.union([_zod.z.array(_zod.z.unknown()), _zod.z.null()]),
1263
- match: _zod.z.union([_zod.z.array(_zod.z.unknown()), _zod.z.null()]),
1264
- sort: _zod.z.union([_zod.z.array(_zod.z.unknown()), _zod.z.null()])
2216
+ var ViewDataSearch = _v3.z.union([
2217
+ _v3.z.object({
2218
+ filter: _v3.z.union([_v3.z.array(_v3.z.unknown()), _v3.z.null()]),
2219
+ tag: _v3.z.union([_v3.z.array(_v3.z.unknown()), _v3.z.null()]),
2220
+ match: _v3.z.union([_v3.z.array(_v3.z.unknown()), _v3.z.null()]),
2221
+ sort: _v3.z.union([_v3.z.array(_v3.z.unknown()), _v3.z.null()])
1265
2222
  }).partial(),
1266
- _zod.z.null()
2223
+ _v3.z.null()
1267
2224
  ]);
1268
- var ViewData = _zod.z.union([
1269
- _zod.z.object({ search: ViewDataSearch }).partial(),
1270
- _zod.z.null()
2225
+ var ViewData = _v3.z.union([
2226
+ _v3.z.object({ search: ViewDataSearch }).partial(),
2227
+ _v3.z.null()
1271
2228
  ]);
1272
- var ViewOptions = _zod.z.union([
1273
- _zod.z.object({
1274
- viewType: _zod.z.literal("monitor"),
1275
- options: _zod.z.object({
1276
- spanType: _zod.z.union([_zod.z.enum(["range", "frame"]), _zod.z.null()]),
1277
- rangeValue: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1278
- frameStart: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1279
- frameEnd: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1280
- tzUTC: _zod.z.union([_zod.z.boolean(), _zod.z.null()]),
1281
- chartVisibility: _zod.z.union([_zod.z.record(_zod.z.boolean()), _zod.z.null()]),
1282
- projectId: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1283
- type: _zod.z.union([_zod.z.enum(["project", "experiment"]), _zod.z.null()]),
1284
- groupBy: _zod.z.union([_zod.z.string(), _zod.z.null()])
2229
+ var ViewOptions = _v3.z.union([
2230
+ _v3.z.object({
2231
+ viewType: _v3.z.literal("monitor"),
2232
+ options: _v3.z.object({
2233
+ spanType: _v3.z.union([_v3.z.enum(["range", "frame"]), _v3.z.null()]),
2234
+ rangeValue: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2235
+ frameStart: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2236
+ frameEnd: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2237
+ tzUTC: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
2238
+ chartVisibility: _v3.z.union([_v3.z.record(_v3.z.boolean()), _v3.z.null()]),
2239
+ projectId: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2240
+ type: _v3.z.union([_v3.z.enum(["project", "experiment"]), _v3.z.null()]),
2241
+ groupBy: _v3.z.union([_v3.z.string(), _v3.z.null()])
1285
2242
  }).partial()
1286
2243
  }),
1287
- _zod.z.object({
1288
- columnVisibility: _zod.z.union([_zod.z.record(_zod.z.boolean()), _zod.z.null()]),
1289
- columnOrder: _zod.z.union([_zod.z.array(_zod.z.string()), _zod.z.null()]),
1290
- columnSizing: _zod.z.union([_zod.z.record(_zod.z.number()), _zod.z.null()]),
1291
- grouping: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1292
- rowHeight: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1293
- tallGroupRows: _zod.z.union([_zod.z.boolean(), _zod.z.null()]),
1294
- layout: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1295
- chartHeight: _zod.z.union([_zod.z.number(), _zod.z.null()]),
1296
- excludedMeasures: _zod.z.union([
1297
- _zod.z.array(
1298
- _zod.z.object({
1299
- type: _zod.z.enum(["none", "score", "metric", "metadata"]),
1300
- value: _zod.z.string()
2244
+ _v3.z.object({
2245
+ columnVisibility: _v3.z.union([_v3.z.record(_v3.z.boolean()), _v3.z.null()]),
2246
+ columnOrder: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]),
2247
+ columnSizing: _v3.z.union([_v3.z.record(_v3.z.number()), _v3.z.null()]),
2248
+ grouping: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2249
+ rowHeight: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2250
+ tallGroupRows: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
2251
+ layout: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2252
+ chartHeight: _v3.z.union([_v3.z.number(), _v3.z.null()]),
2253
+ excludedMeasures: _v3.z.union([
2254
+ _v3.z.array(
2255
+ _v3.z.object({
2256
+ type: _v3.z.enum(["none", "score", "metric", "metadata"]),
2257
+ value: _v3.z.string()
1301
2258
  })
1302
2259
  ),
1303
- _zod.z.null()
2260
+ _v3.z.null()
1304
2261
  ]),
1305
- yMetric: _zod.z.union([
1306
- _zod.z.object({
1307
- type: _zod.z.enum(["none", "score", "metric", "metadata"]),
1308
- value: _zod.z.string()
2262
+ yMetric: _v3.z.union([
2263
+ _v3.z.object({
2264
+ type: _v3.z.enum(["none", "score", "metric", "metadata"]),
2265
+ value: _v3.z.string()
1309
2266
  }),
1310
- _zod.z.null()
2267
+ _v3.z.null()
1311
2268
  ]),
1312
- xAxis: _zod.z.union([
1313
- _zod.z.object({
1314
- type: _zod.z.enum(["none", "score", "metric", "metadata"]),
1315
- value: _zod.z.string()
2269
+ xAxis: _v3.z.union([
2270
+ _v3.z.object({
2271
+ type: _v3.z.enum(["none", "score", "metric", "metadata"]),
2272
+ value: _v3.z.string()
1316
2273
  }),
1317
- _zod.z.null()
2274
+ _v3.z.null()
1318
2275
  ]),
1319
- symbolGrouping: _zod.z.union([
1320
- _zod.z.object({
1321
- type: _zod.z.enum(["none", "score", "metric", "metadata"]),
1322
- value: _zod.z.string()
2276
+ symbolGrouping: _v3.z.union([
2277
+ _v3.z.object({
2278
+ type: _v3.z.enum(["none", "score", "metric", "metadata"]),
2279
+ value: _v3.z.string()
1323
2280
  }),
1324
- _zod.z.null()
2281
+ _v3.z.null()
1325
2282
  ]),
1326
- xAxisAggregation: _zod.z.union([_zod.z.string(), _zod.z.null()]),
1327
- chartAnnotations: _zod.z.union([
1328
- _zod.z.array(_zod.z.object({ id: _zod.z.string(), text: _zod.z.string() })),
1329
- _zod.z.null()
2283
+ xAxisAggregation: _v3.z.union([_v3.z.string(), _v3.z.null()]),
2284
+ chartAnnotations: _v3.z.union([
2285
+ _v3.z.array(_v3.z.object({ id: _v3.z.string(), text: _v3.z.string() })),
2286
+ _v3.z.null()
1330
2287
  ]),
1331
- timeRangeFilter: _zod.z.union([
1332
- _zod.z.string(),
1333
- _zod.z.object({ from: _zod.z.string(), to: _zod.z.string() }),
1334
- _zod.z.null()
2288
+ timeRangeFilter: _v3.z.union([
2289
+ _v3.z.string(),
2290
+ _v3.z.object({ from: _v3.z.string(), to: _v3.z.string() }),
2291
+ _v3.z.null()
1335
2292
  ])
1336
2293
  }).partial(),
1337
- _zod.z.null()
2294
+ _v3.z.null()
1338
2295
  ]);
1339
- var View = _zod.z.object({
1340
- id: _zod.z.string().uuid(),
1341
- object_type: AclObjectType.and(_zod.z.string()),
1342
- object_id: _zod.z.string().uuid(),
1343
- view_type: _zod.z.enum([
2296
+ var View = _v3.z.object({
2297
+ id: _v3.z.string().uuid(),
2298
+ object_type: AclObjectType.and(_v3.z.string()),
2299
+ object_id: _v3.z.string().uuid(),
2300
+ view_type: _v3.z.enum([
1344
2301
  "projects",
1345
2302
  "experiments",
1346
2303
  "experiment",
@@ -1355,56 +2312,56 @@ var View = _zod.z.object({
1355
2312
  "agents",
1356
2313
  "monitor"
1357
2314
  ]),
1358
- name: _zod.z.string(),
1359
- created: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
2315
+ name: _v3.z.string(),
2316
+ created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
1360
2317
  view_data: ViewData.optional(),
1361
2318
  options: ViewOptions.optional(),
1362
- user_id: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional(),
1363
- deleted_at: _zod.z.union([_zod.z.string(), _zod.z.null()]).optional()
2319
+ user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
2320
+ deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
1364
2321
  });
1365
2322
 
1366
2323
  // src/logger.ts
1367
2324
  var _functions = require('@vercel/functions');
1368
2325
  var _mustache = require('mustache'); var _mustache2 = _interopRequireDefault(_mustache);
1369
-
2326
+ var _zod = require('zod');
1370
2327
 
1371
2328
  // src/functions/stream.ts
1372
2329
 
1373
2330
 
1374
2331
  var _eventsourceparser = require('eventsource-parser');
1375
2332
 
1376
- var braintrustStreamChunkSchema = _zod.z.union([
1377
- _zod.z.object({
1378
- type: _zod.z.literal("text_delta"),
1379
- data: _zod.z.string()
2333
+ var braintrustStreamChunkSchema = _v3.z.union([
2334
+ _v3.z.object({
2335
+ type: _v3.z.literal("text_delta"),
2336
+ data: _v3.z.string()
1380
2337
  }),
1381
- _zod.z.object({
1382
- type: _zod.z.literal("reasoning_delta"),
1383
- data: _zod.z.string()
2338
+ _v3.z.object({
2339
+ type: _v3.z.literal("reasoning_delta"),
2340
+ data: _v3.z.string()
1384
2341
  }),
1385
- _zod.z.object({
1386
- type: _zod.z.literal("json_delta"),
1387
- data: _zod.z.string()
2342
+ _v3.z.object({
2343
+ type: _v3.z.literal("json_delta"),
2344
+ data: _v3.z.string()
1388
2345
  }),
1389
- _zod.z.object({
1390
- type: _zod.z.literal("error"),
1391
- data: _zod.z.string()
2346
+ _v3.z.object({
2347
+ type: _v3.z.literal("error"),
2348
+ data: _v3.z.string()
1392
2349
  }),
1393
- _zod.z.object({
1394
- type: _zod.z.literal("console"),
2350
+ _v3.z.object({
2351
+ type: _v3.z.literal("console"),
1395
2352
  data: SSEConsoleEventData
1396
2353
  }),
1397
- _zod.z.object({
1398
- type: _zod.z.literal("progress"),
2354
+ _v3.z.object({
2355
+ type: _v3.z.literal("progress"),
1399
2356
  data: SSEProgressEventData
1400
2357
  }),
1401
- _zod.z.object({
1402
- type: _zod.z.literal("start"),
1403
- data: _zod.z.string()
2358
+ _v3.z.object({
2359
+ type: _v3.z.literal("start"),
2360
+ data: _v3.z.string()
1404
2361
  }),
1405
- _zod.z.object({
1406
- type: _zod.z.literal("done"),
1407
- data: _zod.z.string()
2362
+ _v3.z.object({
2363
+ type: _v3.z.literal("done"),
2364
+ data: _v3.z.string()
1408
2365
  })
1409
2366
  ]);
1410
2367
  var BraintrustStream = class _BraintrustStream {
@@ -1996,12 +2953,11 @@ function objectIsEmpty(obj) {
1996
2953
 
1997
2954
  // src/mustache-utils.ts
1998
2955
 
1999
-
2000
2956
  function lintTemplate(template, context) {
2001
2957
  const variables = getMustacheVars(template);
2002
2958
  for (const variable of variables) {
2003
2959
  const arrPathsReplaced = variable[1].replaceAll(/\.\d+/g, ".0");
2004
- const fieldExists = _core.getObjValueByPath.call(void 0, context, arrPathsReplaced.split(".")) !== void 0;
2960
+ const fieldExists = getObjValueByPath(context, arrPathsReplaced.split(".")) !== void 0;
2005
2961
  if (!fieldExists) {
2006
2962
  throw new Error(`Variable '${variable[1]}' does not exist.`);
2007
2963
  }
@@ -2012,13 +2968,12 @@ function getMustacheVars(prompt) {
2012
2968
  return _mustache2.default.parse(prompt).filter(
2013
2969
  (span) => span[0] === "name" || span[0] === "&"
2014
2970
  );
2015
- } catch (e2) {
2971
+ } catch (e4) {
2016
2972
  return [];
2017
2973
  }
2018
2974
  }
2019
2975
 
2020
2976
  // src/logger.ts
2021
-
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);
@@ -2079,7 +3034,7 @@ var NoopSpan = (_class4 = class {
2079
3034
  return this;
2080
3035
  }
2081
3036
  end(args) {
2082
- return _nullishCoalesce(_optionalChain([args, 'optionalAccess', _2 => _2.endTime]), () => ( getCurrentUnixTimestamp()));
3037
+ return _nullishCoalesce(_optionalChain([args, 'optionalAccess', _12 => _12.endTime]), () => ( getCurrentUnixTimestamp()));
2083
3038
  }
2084
3039
  async export() {
2085
3040
  return "";
@@ -2103,6 +3058,20 @@ var NoopSpan = (_class4 = class {
2103
3058
  state() {
2104
3059
  return _internalGetGlobalState();
2105
3060
  }
3061
+ // Custom inspect for Node.js console.log
3062
+ [Symbol.for("nodejs.util.inspect.custom")]() {
3063
+ return `NoopSpan {
3064
+ kind: '${this.kind}',
3065
+ id: '${this.id}',
3066
+ spanId: '${this.spanId}',
3067
+ rootSpanId: '${this.rootSpanId}',
3068
+ spanParents: ${JSON.stringify(this.spanParents)}
3069
+ }`;
3070
+ }
3071
+ // Custom toString
3072
+ toString() {
3073
+ return `NoopSpan(id=${this.id}, spanId=${this.spanId})`;
3074
+ }
2106
3075
  }, _class4);
2107
3076
  var NOOP_SPAN = new NoopSpan();
2108
3077
  var NOOP_SPAN_PERMALINK = "https://braintrust.dev/noop-span";
@@ -2253,8 +3222,8 @@ var BraintrustState = (_class5 = class _BraintrustState {
2253
3222
  setFetch(fetch2) {
2254
3223
  this.loginParams.fetch = fetch2;
2255
3224
  this.fetch = fetch2;
2256
- _optionalChain([this, 'access', _3 => _3._apiConn, 'optionalAccess', _4 => _4.setFetch, 'call', _5 => _5(fetch2)]);
2257
- _optionalChain([this, 'access', _6 => _6._appConn, 'optionalAccess', _7 => _7.setFetch, 'call', _8 => _8(fetch2)]);
3225
+ _optionalChain([this, 'access', _13 => _13._apiConn, 'optionalAccess', _14 => _14.setFetch, 'call', _15 => _15(fetch2)]);
3226
+ _optionalChain([this, 'access', _16 => _16._appConn, 'optionalAccess', _17 => _17.setFetch, 'call', _18 => _18(fetch2)]);
2258
3227
  }
2259
3228
  setMaskingFunction(maskingFunction) {
2260
3229
  this.bgLogger().setMaskingFunction(maskingFunction);
@@ -2323,6 +3292,37 @@ var BraintrustState = (_class5 = class _BraintrustState {
2323
3292
  enforceQueueSizeLimit(enforce) {
2324
3293
  this._bgLogger.get().enforceQueueSizeLimit(enforce);
2325
3294
  }
3295
+ // Custom serialization to avoid logging sensitive data
3296
+ toJSON() {
3297
+ return {
3298
+ id: this.id,
3299
+ orgId: this.orgId,
3300
+ orgName: this.orgName,
3301
+ appUrl: this.appUrl,
3302
+ appPublicUrl: this.appPublicUrl,
3303
+ apiUrl: this.apiUrl,
3304
+ proxyUrl: this.proxyUrl,
3305
+ loggedIn: this.loggedIn
3306
+ // Explicitly exclude loginToken, _apiConn, _appConn, _proxyConn and other sensitive fields
3307
+ };
3308
+ }
3309
+ // Custom inspect for Node.js console.log
3310
+ [Symbol.for("nodejs.util.inspect.custom")]() {
3311
+ return `BraintrustState {
3312
+ id: '${this.id}',
3313
+ orgId: ${this.orgId ? `'${this.orgId}'` : "null"},
3314
+ orgName: ${this.orgName ? `'${this.orgName}'` : "null"},
3315
+ appUrl: ${this.appUrl ? `'${this.appUrl}'` : "null"},
3316
+ apiUrl: ${this.apiUrl ? `'${this.apiUrl}'` : "null"},
3317
+ proxyUrl: ${this.proxyUrl ? `'${this.proxyUrl}'` : "null"},
3318
+ loggedIn: ${this.loggedIn},
3319
+ loginToken: '[REDACTED]'
3320
+ }`;
3321
+ }
3322
+ // Custom toString
3323
+ toString() {
3324
+ return `BraintrustState(id=${this.id}, org=${this.orgName || "none"}, loggedIn=${this.loggedIn})`;
3325
+ }
2326
3326
  }, _class5);
2327
3327
  var _globalState;
2328
3328
  function useTestBackgroundLogger() {
@@ -2335,7 +3335,7 @@ function useTestBackgroundLogger() {
2335
3335
  return logger;
2336
3336
  }
2337
3337
  function clearTestBackgroundLogger() {
2338
- _optionalChain([_internalGetGlobalState, 'call', _9 => _9(), 'optionalAccess', _10 => _10.setOverrideBgLogger, 'call', _11 => _11(null)]);
3338
+ _optionalChain([_internalGetGlobalState, 'call', _19 => _19(), 'optionalAccess', _20 => _20.setOverrideBgLogger, 'call', _21 => _21(null)]);
2339
3339
  }
2340
3340
  function initTestExperiment(experimentName, projectName) {
2341
3341
  setInitialTestState();
@@ -2426,7 +3426,7 @@ var HTTPConnection = class _HTTPConnection {
2426
3426
  }
2427
3427
  async get(path, params = void 0, config) {
2428
3428
  const { headers, ...rest } = config || {};
2429
- const url = new URL(_core._urljoin.call(void 0, this.base_url, path));
3429
+ const url = new URL(_urljoin(this.base_url, path));
2430
3430
  url.search = new URLSearchParams(
2431
3431
  params ? Object.entries(params).filter(([_, v]) => v !== void 0).flatMap(
2432
3432
  ([k, v]) => v !== void 0 ? typeof v === "string" ? [[k, v]] : v.map((x) => [k, x]) : []
@@ -2453,7 +3453,7 @@ var HTTPConnection = class _HTTPConnection {
2453
3453
  const this_base_url = this.base_url;
2454
3454
  const this_headers = this.headers;
2455
3455
  return await checkResponse(
2456
- await this_fetch(_core._urljoin.call(void 0, this_base_url, path), {
3456
+ await this_fetch(_urljoin(this_base_url, path), {
2457
3457
  method: "POST",
2458
3458
  headers: {
2459
3459
  Accept: "application/json",
@@ -2490,6 +3490,17 @@ var HTTPConnection = class _HTTPConnection {
2490
3490
  });
2491
3491
  return await resp.json();
2492
3492
  }
3493
+ // Custom inspect for Node.js console.log
3494
+ [Symbol.for("nodejs.util.inspect.custom")]() {
3495
+ return `HTTPConnection {
3496
+ base_url: '${this.base_url}',
3497
+ token: '[REDACTED]'
3498
+ }`;
3499
+ }
3500
+ // Custom toString
3501
+ toString() {
3502
+ return `HTTPConnection(${this.base_url})`;
3503
+ }
2493
3504
  };
2494
3505
  var BaseAttachment = class {
2495
3506
 
@@ -2848,8 +3859,8 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
2848
3859
  source: inputSource
2849
3860
  }) {
2850
3861
  const source = _nullishCoalesce(inputSource, () => ( "external"));
2851
- if (!_core.VALID_SOURCES.includes(source)) {
2852
- throw new Error(`source must be one of ${_core.VALID_SOURCES}`);
3862
+ if (!VALID_SOURCES.includes(source)) {
3863
+ throw new Error(`source must be one of ${VALID_SOURCES}`);
2853
3864
  }
2854
3865
  if (isEmpty(scores) && isEmpty(expected) && isEmpty(tags) && isEmpty(comment)) {
2855
3866
  throw new Error(
@@ -2866,7 +3877,7 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
2866
3877
  updateEvent = Object.fromEntries(
2867
3878
  Object.entries(updateEvent).filter(([_, v]) => !isEmpty(v))
2868
3879
  );
2869
- const parentIds = async () => new (0, _core.SpanComponentsV3)({
3880
+ const parentIds = async () => new SpanComponentsV3({
2870
3881
  object_type: parentObjectType,
2871
3882
  object_id: await parentObjectId.get()
2872
3883
  }).objectIdFields();
@@ -2876,9 +3887,9 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
2876
3887
  id,
2877
3888
  ...updateEvent,
2878
3889
  ...await parentIds(),
2879
- [_core.AUDIT_SOURCE_FIELD]: source,
2880
- [_core.AUDIT_METADATA_FIELD]: metadata,
2881
- [_core.IS_MERGE_FIELD]: true
3890
+ [AUDIT_SOURCE_FIELD]: source,
3891
+ [AUDIT_METADATA_FIELD]: metadata,
3892
+ [IS_MERGE_FIELD]: true
2882
3893
  };
2883
3894
  });
2884
3895
  state.bgLogger().log([record]);
@@ -2897,8 +3908,8 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
2897
3908
  text: comment
2898
3909
  },
2899
3910
  ...await parentIds(),
2900
- [_core.AUDIT_SOURCE_FIELD]: source,
2901
- [_core.AUDIT_METADATA_FIELD]: metadata
3911
+ [AUDIT_SOURCE_FIELD]: source,
3912
+ [AUDIT_METADATA_FIELD]: metadata
2902
3913
  };
2903
3914
  });
2904
3915
  state.bgLogger().log([record]);
@@ -2917,7 +3928,7 @@ function updateSpanImpl({
2917
3928
  ...event
2918
3929
  })
2919
3930
  );
2920
- const parentIds = async () => new (0, _core.SpanComponentsV3)({
3931
+ const parentIds = async () => new SpanComponentsV3({
2921
3932
  object_type: parentObjectType,
2922
3933
  object_id: await parentObjectId.get()
2923
3934
  }).objectIdFields();
@@ -2925,7 +3936,7 @@ function updateSpanImpl({
2925
3936
  id,
2926
3937
  ...updateEvent,
2927
3938
  ...await parentIds(),
2928
- [_core.IS_MERGE_FIELD]: true
3939
+ [IS_MERGE_FIELD]: true
2929
3940
  }));
2930
3941
  state.bgLogger().log([record]);
2931
3942
  }
@@ -2935,7 +3946,7 @@ function updateSpan({
2935
3946
  ...event
2936
3947
  }) {
2937
3948
  const resolvedState = _nullishCoalesce(state, () => ( _globalState));
2938
- const components = _core.SpanComponentsV3.fromStr(exported);
3949
+ const components = SpanComponentsV3.fromStr(exported);
2939
3950
  if (!components.data.row_id) {
2940
3951
  throw new Error("Exported span must have a row id");
2941
3952
  }
@@ -2960,15 +3971,15 @@ function spanComponentsToObjectIdLambda(state, components) {
2960
3971
  );
2961
3972
  }
2962
3973
  switch (components.data.object_type) {
2963
- case _core.SpanObjectTypeV3.EXPERIMENT:
3974
+ case 1 /* EXPERIMENT */:
2964
3975
  throw new Error(
2965
3976
  "Impossible: computeObjectMetadataArgs not supported for experiments"
2966
3977
  );
2967
- case _core.SpanObjectTypeV3.PLAYGROUND_LOGS:
3978
+ case 3 /* PLAYGROUND_LOGS */:
2968
3979
  throw new Error(
2969
3980
  "Impossible: computeObjectMetadataArgs not supported for prompt sessions"
2970
3981
  );
2971
- case _core.SpanObjectTypeV3.PROJECT_LOGS:
3982
+ case 2 /* PROJECT_LOGS */:
2972
3983
  return async () => (await computeLoggerMetadata(state, {
2973
3984
  ...components.data.compute_object_metadata_args
2974
3985
  })).project.id;
@@ -2997,9 +4008,9 @@ async function permalink(slug, opts) {
2997
4008
  if (slug === "") {
2998
4009
  return NOOP_SPAN_PERMALINK;
2999
4010
  }
3000
- const state = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _12 => _12.state]), () => ( _globalState));
4011
+ const state = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _22 => _22.state]), () => ( _globalState));
3001
4012
  const getOrgName = async () => {
3002
- if (_optionalChain([opts, 'optionalAccess', _13 => _13.orgName])) {
4013
+ if (_optionalChain([opts, 'optionalAccess', _23 => _23.orgName])) {
3003
4014
  return opts.orgName;
3004
4015
  }
3005
4016
  await state.login({});
@@ -3009,7 +4020,7 @@ async function permalink(slug, opts) {
3009
4020
  return state.orgName;
3010
4021
  };
3011
4022
  const getAppUrl = async () => {
3012
- if (_optionalChain([opts, 'optionalAccess', _14 => _14.appUrl])) {
4023
+ if (_optionalChain([opts, 'optionalAccess', _24 => _24.appUrl])) {
3013
4024
  return opts.appUrl;
3014
4025
  }
3015
4026
  await state.login({});
@@ -3019,8 +4030,8 @@ async function permalink(slug, opts) {
3019
4030
  return state.appUrl;
3020
4031
  };
3021
4032
  try {
3022
- const components = _core.SpanComponentsV3.fromStr(slug);
3023
- const object_type = _core.spanObjectTypeV3ToString.call(void 0, components.data.object_type);
4033
+ const components = SpanComponentsV3.fromStr(slug);
4034
+ const object_type = spanObjectTypeV3ToString(components.data.object_type);
3024
4035
  const [orgName, appUrl, object_id] = await Promise.all([
3025
4036
  getOrgName(),
3026
4037
  getAppUrl(),
@@ -3047,7 +4058,7 @@ function startSpanParentArgs(args) {
3047
4058
  if (args.parentSpanIds) {
3048
4059
  throw new Error("Cannot specify both parent and parentSpanIds");
3049
4060
  }
3050
- const parentComponents = _core.SpanComponentsV3.fromStr(args.parent);
4061
+ const parentComponents = SpanComponentsV3.fromStr(args.parent);
3051
4062
  if (args.parentObjectType !== parentComponents.data.object_type) {
3052
4063
  throw new Error(
3053
4064
  `Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
@@ -3120,7 +4131,7 @@ var Logger = (_class6 = class {
3120
4131
  return (async () => (await this.project).id)();
3121
4132
  }
3122
4133
  parentObjectType() {
3123
- return _core.SpanObjectTypeV3.PROJECT_LOGS;
4134
+ return 2 /* PROJECT_LOGS */;
3124
4135
  }
3125
4136
  /**
3126
4137
  * Log a single event. The event will be batched and uploaded behind the scenes if `logOptions.asyncFlush` is true.
@@ -3139,7 +4150,7 @@ var Logger = (_class6 = class {
3139
4150
  * @returns The `id` of the logged event.
3140
4151
  */
3141
4152
  log(event, options) {
3142
- if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _15 => _15.allowConcurrentWithSpans])) {
4153
+ if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _25 => _25.allowConcurrentWithSpans])) {
3143
4154
  throw new Error(
3144
4155
  "Cannot run toplevel `log` method while using spans. To log to the span, call `logger.traced` and then log with `span.log`"
3145
4156
  );
@@ -3207,14 +4218,14 @@ var Logger = (_class6 = class {
3207
4218
  state: this.state,
3208
4219
  ...startSpanParentArgs({
3209
4220
  state: this.state,
3210
- parent: _optionalChain([args, 'optionalAccess', _16 => _16.parent]),
4221
+ parent: _optionalChain([args, 'optionalAccess', _26 => _26.parent]),
3211
4222
  parentObjectType: this.parentObjectType(),
3212
4223
  parentObjectId: this.lazyId,
3213
4224
  parentComputeObjectMetadataArgs: this.computeMetadataArgs,
3214
- parentSpanIds: _optionalChain([args, 'optionalAccess', _17 => _17.parentSpanIds]),
3215
- propagatedEvent: _optionalChain([args, 'optionalAccess', _18 => _18.propagatedEvent])
4225
+ parentSpanIds: _optionalChain([args, 'optionalAccess', _27 => _27.parentSpanIds]),
4226
+ propagatedEvent: _optionalChain([args, 'optionalAccess', _28 => _28.propagatedEvent])
3216
4227
  }),
3217
- defaultRootType: _core.SpanTypeAttribute.TASK
4228
+ defaultRootType: "task" /* TASK */
3218
4229
  });
3219
4230
  }
3220
4231
  /**
@@ -3256,7 +4267,7 @@ var Logger = (_class6 = class {
3256
4267
  * See {@link Span.startSpan} for more details.
3257
4268
  */
3258
4269
  async export() {
3259
- return new (0, _core.SpanComponentsV3)({
4270
+ return new SpanComponentsV3({
3260
4271
  object_type: this.parentObjectType(),
3261
4272
  ...this.computeMetadataArgs && !this.lazyId.hasSucceeded ? { compute_object_metadata_args: this.computeMetadataArgs } : { object_id: await this.lazyId.get() }
3262
4273
  }).toStr();
@@ -3281,7 +4292,7 @@ function castLogger(logger, asyncFlush) {
3281
4292
  return logger;
3282
4293
  }
3283
4294
  function constructLogs3Data(items) {
3284
- return `{"rows": ${_core.constructJsonArray.call(void 0, items)}, "api_version": 2}`;
4295
+ return `{"rows": ${constructJsonArray(items)}, "api_version": 2}`;
3285
4296
  }
3286
4297
  function now() {
3287
4298
  return (/* @__PURE__ */ new Date()).getTime();
@@ -3307,7 +4318,7 @@ var TestBackgroundLogger = (_class7 = class {constructor() { _class7.prototype._
3307
4318
  events.push(await event.get());
3308
4319
  }
3309
4320
  }
3310
- const batch = _core.mergeRowBatch.call(void 0, events);
4321
+ const batch = mergeRowBatch(events);
3311
4322
  let flatBatch = batch.flat();
3312
4323
  if (this.maskingFunction) {
3313
4324
  flatBatch = flatBatch.map((item) => {
@@ -3450,7 +4461,7 @@ var HTTPBackgroundLogger = (_class8 = class _HTTPBackgroundLogger {
3450
4461
  this.queue.clear();
3451
4462
  return;
3452
4463
  }
3453
- const batchSize = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _19 => _19.batchSize]), () => ( this.defaultBatchSize));
4464
+ const batchSize = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _29 => _29.batchSize]), () => ( this.defaultBatchSize));
3454
4465
  const wrappedItems = this.queue.drain();
3455
4466
  const [allItems, attachments] = await this.unwrapLazyValues(wrappedItems);
3456
4467
  if (allItems.length === 0) {
@@ -3459,7 +4470,7 @@ var HTTPBackgroundLogger = (_class8 = class _HTTPBackgroundLogger {
3459
4470
  const allItemsStr = allItems.map(
3460
4471
  (bucket) => bucket.map((item) => JSON.stringify(item))
3461
4472
  );
3462
- const batchSets = _core.batchItems.call(void 0, {
4473
+ const batchSets = batchItems({
3463
4474
  items: allItemsStr,
3464
4475
  batchMaxNumItems: batchSize,
3465
4476
  batchMaxNumBytes: this.maxRequestSize / 2
@@ -3513,7 +4524,7 @@ var HTTPBackgroundLogger = (_class8 = class _HTTPBackgroundLogger {
3513
4524
  const items = await Promise.all(wrappedItems.map((x) => x.get()));
3514
4525
  const attachments = [];
3515
4526
  items.forEach((item) => extractAttachments(item, attachments));
3516
- let mergedItems = _core.mergeRowBatch.call(void 0, items);
4527
+ let mergedItems = mergeRowBatch(items);
3517
4528
  if (this.maskingFunction) {
3518
4529
  mergedItems = mergedItems.map(
3519
4530
  (batch) => batch.map((item) => {
@@ -3699,10 +4710,10 @@ Error: ${errorText}`;
3699
4710
  } catch (err) {
3700
4711
  if (err instanceof AggregateError) {
3701
4712
  for (const e of err.errors) {
3702
- _optionalChain([this, 'access', _20 => _20.onFlushError, 'optionalCall', _21 => _21(e)]);
4713
+ _optionalChain([this, 'access', _30 => _30.onFlushError, 'optionalCall', _31 => _31(e)]);
3703
4714
  }
3704
4715
  } else {
3705
- _optionalChain([this, 'access', _22 => _22.onFlushError, 'optionalCall', _23 => _23(err)]);
4716
+ _optionalChain([this, 'access', _32 => _32.onFlushError, 'optionalCall', _33 => _33(err)]);
3706
4717
  }
3707
4718
  this.activeFlushError = err;
3708
4719
  } finally {
@@ -3832,7 +4843,7 @@ function init(projectOrOptions, optionalOptions) {
3832
4843
  }
3833
4844
  };
3834
4845
  if (gitMetadataSettings) {
3835
- mergedGitMetadataSettings = _core.mergeGitMetadataSettings.call(void 0,
4846
+ mergedGitMetadataSettings = mergeGitMetadataSettings(
3836
4847
  mergedGitMetadataSettings,
3837
4848
  gitMetadataSettings
3838
4849
  );
@@ -4257,7 +5268,7 @@ async function loginToState(options = {}) {
4257
5268
  return state;
4258
5269
  } else {
4259
5270
  const resp = await checkResponse(
4260
- await fetch2(_core._urljoin.call(void 0, state.appUrl, `/api/apikey/login`), {
5271
+ await fetch2(_urljoin(state.appUrl, `/api/apikey/login`), {
4261
5272
  method: "POST",
4262
5273
  headers: {
4263
5274
  "Content-Type": "application/json",
@@ -4315,23 +5326,25 @@ async function summarize(options = {}) {
4315
5326
  return await e.summarize(options);
4316
5327
  }
4317
5328
  function currentExperiment(options) {
4318
- const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _24 => _24.state]), () => ( _globalState));
5329
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _34 => _34.state]), () => ( _globalState));
4319
5330
  return state.currentExperiment;
4320
5331
  }
4321
5332
  function currentLogger(options) {
4322
- const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _25 => _25.state]), () => ( _globalState));
4323
- return castLogger(state.currentLogger, _optionalChain([options, 'optionalAccess', _26 => _26.asyncFlush]));
5333
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _35 => _35.state]), () => ( _globalState));
5334
+ return castLogger(state.currentLogger, _optionalChain([options, 'optionalAccess', _36 => _36.asyncFlush]));
4324
5335
  }
4325
5336
  function currentSpan(options) {
4326
- const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _27 => _27.state]), () => ( _globalState));
5337
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _37 => _37.state]), () => ( _globalState));
4327
5338
  return _nullishCoalesce(state.currentSpan.getStore(), () => ( NOOP_SPAN));
4328
5339
  }
4329
5340
  function getSpanParentObject(options) {
4330
- const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _28 => _28.state]), () => ( _globalState));
5341
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _38 => _38.state]), () => ( _globalState));
4331
5342
  const parentSpan = currentSpan({ state });
4332
5343
  if (!Object.is(parentSpan, NOOP_SPAN)) {
4333
5344
  return parentSpan;
4334
5345
  }
5346
+ const parentStr = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _39 => _39.parent]), () => ( state.currentParent.getStore()));
5347
+ if (parentStr) return SpanComponentsV3.fromStr(parentStr);
4335
5348
  const experiment = currentExperiment();
4336
5349
  if (experiment) {
4337
5350
  return experiment;
@@ -4359,7 +5372,7 @@ function traced(callback, args) {
4359
5372
  const { span, isSyncFlushLogger } = startSpanAndIsLogger(args);
4360
5373
  const ret = runCatchFinally(
4361
5374
  () => {
4362
- if (_nullishCoalesce(_optionalChain([args, 'optionalAccess', _29 => _29.setCurrent]), () => ( true))) {
5375
+ if (_nullishCoalesce(_optionalChain([args, 'optionalAccess', _40 => _40.setCurrent]), () => ( true))) {
4363
5376
  return withCurrent(span, callback);
4364
5377
  } else {
4365
5378
  return callback(span);
@@ -4371,7 +5384,7 @@ function traced(callback, args) {
4371
5384
  },
4372
5385
  () => span.end()
4373
5386
  );
4374
- if (_optionalChain([args, 'optionalAccess', _30 => _30.asyncFlush]) === void 0 || _optionalChain([args, 'optionalAccess', _31 => _31.asyncFlush])) {
5387
+ if (_optionalChain([args, 'optionalAccess', _41 => _41.asyncFlush]) === void 0 || _optionalChain([args, 'optionalAccess', _42 => _42.asyncFlush])) {
4375
5388
  return ret;
4376
5389
  } else {
4377
5390
  return (async () => {
@@ -4495,14 +5508,14 @@ function wrapTraced(fn, args) {
4495
5508
  };
4496
5509
  const hasExplicitInput = args && args.event && "input" in args.event && args.event.input !== void 0;
4497
5510
  const hasExplicitOutput = args && args.event && args.event.output !== void 0;
4498
- const noTraceIO = _optionalChain([args, 'optionalAccess', _32 => _32.noTraceIO]) || hasExplicitInput || hasExplicitOutput;
5511
+ const noTraceIO = _optionalChain([args, 'optionalAccess', _43 => _43.noTraceIO]) || hasExplicitInput || hasExplicitOutput;
4499
5512
  if (isGeneratorFunction(fn)) {
4500
5513
  return wrapTracedSyncGenerator(fn, spanArgs, !!noTraceIO);
4501
5514
  }
4502
5515
  if (isAsyncGeneratorFunction(fn)) {
4503
5516
  return wrapTracedAsyncGenerator(fn, spanArgs, !!noTraceIO);
4504
5517
  }
4505
- if (_optionalChain([args, 'optionalAccess', _33 => _33.asyncFlush])) {
5518
+ if (_optionalChain([args, 'optionalAccess', _44 => _44.asyncFlush])) {
4506
5519
  return (...fnArgs) => traced((span) => {
4507
5520
  if (!hasExplicitInput) {
4508
5521
  span.log({ input: fnArgs });
@@ -4540,43 +5553,43 @@ function startSpan(args) {
4540
5553
  return startSpanAndIsLogger(args).span;
4541
5554
  }
4542
5555
  async function flush(options) {
4543
- const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _34 => _34.state]), () => ( _globalState));
5556
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _45 => _45.state]), () => ( _globalState));
4544
5557
  return await state.bgLogger().flush();
4545
5558
  }
4546
5559
  function setFetch(fetch2) {
4547
5560
  _globalState.setFetch(fetch2);
4548
5561
  }
4549
5562
  function startSpanAndIsLogger(args) {
4550
- const state = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _35 => _35.state]), () => ( _globalState));
4551
- const parentStr = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _36 => _36.parent]), () => ( state.currentParent.getStore()));
4552
- const components = parentStr ? _core.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
5563
+ const state = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _46 => _46.state]), () => ( _globalState));
5564
+ const parentObject = getSpanParentObject({
5565
+ asyncFlush: _optionalChain([args, 'optionalAccess', _47 => _47.asyncFlush]),
5566
+ parent: _optionalChain([args, 'optionalAccess', _48 => _48.parent]),
5567
+ state
5568
+ });
5569
+ if (parentObject instanceof SpanComponentsV3) {
5570
+ const parentSpanIds = parentObject.data.row_id ? {
5571
+ spanId: parentObject.data.span_id,
5572
+ rootSpanId: parentObject.data.root_span_id
4557
5573
  } : void 0;
4558
5574
  const span = new SpanImpl({
4559
5575
  state,
4560
5576
  ...args,
4561
- parentObjectType: components.data.object_type,
5577
+ parentObjectType: parentObject.data.object_type,
4562
5578
  parentObjectId: new LazyValue(
4563
- spanComponentsToObjectIdLambda(state, components)
5579
+ spanComponentsToObjectIdLambda(state, parentObject)
4564
5580
  ),
4565
- parentComputeObjectMetadataArgs: _nullishCoalesce(components.data.compute_object_metadata_args, () => ( void 0)),
5581
+ parentComputeObjectMetadataArgs: _nullishCoalesce(parentObject.data.compute_object_metadata_args, () => ( void 0)),
4566
5582
  parentSpanIds,
4567
- propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _37 => _37.propagatedEvent]), () => ( // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
4568
- (_nullishCoalesce(components.data.propagated_event, () => ( void 0)))))
5583
+ propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _49 => _49.propagatedEvent]), () => ( // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
5584
+ (_nullishCoalesce(parentObject.data.propagated_event, () => ( void 0)))))
4569
5585
  });
4570
5586
  return {
4571
5587
  span,
4572
- isSyncFlushLogger: components.data.object_type === _core.SpanObjectTypeV3.PROJECT_LOGS && // Since there's no parent logger here, we're free to choose the async flush
5588
+ isSyncFlushLogger: parentObject.data.object_type === 2 /* PROJECT_LOGS */ && // Since there's no parent logger here, we're free to choose the async flush
4573
5589
  // behavior, and therefore propagate along whatever we get from the arguments
4574
- _optionalChain([args, 'optionalAccess', _38 => _38.asyncFlush]) === false
5590
+ _optionalChain([args, 'optionalAccess', _50 => _50.asyncFlush]) === false
4575
5591
  };
4576
5592
  } else {
4577
- const parentObject = getSpanParentObject({
4578
- asyncFlush: _optionalChain([args, 'optionalAccess', _39 => _39.asyncFlush])
4579
- });
4580
5593
  const span = parentObject.startSpan(args);
4581
5594
  return {
4582
5595
  span,
@@ -4763,10 +5776,10 @@ function extractAttachments(event, attachments) {
4763
5776
  event[key] = value.reference;
4764
5777
  continue;
4765
5778
  }
4766
- if (_optionalChain([value, 'optionalAccess', _40 => _40.type]) === BRAINTRUST_ATTACHMENT && value.key && !value.uploader) {
5779
+ if (_optionalChain([value, 'optionalAccess', _51 => _51.type]) === BRAINTRUST_ATTACHMENT && value.key && !value.uploader) {
4767
5780
  continue;
4768
5781
  }
4769
- if (_optionalChain([value, 'optionalAccess', _41 => _41.reference, 'optionalAccess', _42 => _42.type]) === BRAINTRUST_ATTACHMENT && _optionalChain([value, 'optionalAccess', _43 => _43.uploader])) {
5782
+ if (_optionalChain([value, 'optionalAccess', _52 => _52.reference, 'optionalAccess', _53 => _53.type]) === BRAINTRUST_ATTACHMENT && _optionalChain([value, 'optionalAccess', _54 => _54.uploader])) {
4770
5783
  const attachment = new Attachment({
4771
5784
  data: value.dataDebugString,
4772
5785
  filename: value.reference.filename,
@@ -4904,7 +5917,7 @@ var ObjectFetcher = (_class9 = class {
4904
5917
  throw new Error("Too many BTQL iterations");
4905
5918
  }
4906
5919
  }
4907
- this._fetchedData = this.mutateRecord ? _optionalChain([data, 'optionalAccess', _44 => _44.map, 'call', _45 => _45(this.mutateRecord)]) : data;
5920
+ this._fetchedData = this.mutateRecord ? _optionalChain([data, 'optionalAccess', _55 => _55.map, 'call', _56 => _56(this.mutateRecord)]) : data;
4908
5921
  }
4909
5922
  return this._fetchedData || [];
4910
5923
  }
@@ -4918,7 +5931,7 @@ var ObjectFetcher = (_class9 = class {
4918
5931
  const fetchedData = await this.fetchedData();
4919
5932
  let maxVersion = void 0;
4920
5933
  for (const record of fetchedData) {
4921
- const xactId = String(_nullishCoalesce(record[_core.TRANSACTION_ID_FIELD], () => ( "0")));
5934
+ const xactId = String(_nullishCoalesce(record[TRANSACTION_ID_FIELD], () => ( "0")));
4922
5935
  if (maxVersion === void 0 || xactId > maxVersion) {
4923
5936
  maxVersion = xactId;
4924
5937
  }
@@ -4961,7 +5974,7 @@ var Experiment2 = (_class10 = class extends ObjectFetcher {
4961
5974
  })();
4962
5975
  }
4963
5976
  parentObjectType() {
4964
- return _core.SpanObjectTypeV3.EXPERIMENT;
5977
+ return 1 /* EXPERIMENT */;
4965
5978
  }
4966
5979
  async getState() {
4967
5980
  await this.lazyMetadata.get();
@@ -4985,7 +5998,7 @@ var Experiment2 = (_class10 = class extends ObjectFetcher {
4985
5998
  * @returns The `id` of the logged event.
4986
5999
  */
4987
6000
  log(event, options) {
4988
- if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _46 => _46.allowConcurrentWithSpans])) {
6001
+ if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _57 => _57.allowConcurrentWithSpans])) {
4989
6002
  throw new Error(
4990
6003
  "Cannot run toplevel `log` method while using spans. To log to the span, call `experiment.traced` and then log with `span.log`"
4991
6004
  );
@@ -5038,14 +6051,14 @@ var Experiment2 = (_class10 = class extends ObjectFetcher {
5038
6051
  state: this.state,
5039
6052
  ...startSpanParentArgs({
5040
6053
  state: this.state,
5041
- parent: _optionalChain([args, 'optionalAccess', _47 => _47.parent]),
6054
+ parent: _optionalChain([args, 'optionalAccess', _58 => _58.parent]),
5042
6055
  parentObjectType: this.parentObjectType(),
5043
6056
  parentObjectId: this.lazyId,
5044
6057
  parentComputeObjectMetadataArgs: void 0,
5045
6058
  parentSpanIds: void 0,
5046
- propagatedEvent: _optionalChain([args, 'optionalAccess', _48 => _48.propagatedEvent])
6059
+ propagatedEvent: _optionalChain([args, 'optionalAccess', _59 => _59.propagatedEvent])
5047
6060
  }),
5048
- defaultRootType: _core.SpanTypeAttribute.EVAL
6061
+ defaultRootType: "eval" /* EVAL */
5049
6062
  });
5050
6063
  }
5051
6064
  async fetchBaseExperiment() {
@@ -5169,7 +6182,7 @@ View complete results in Braintrust or run experiment.summarize() again.`
5169
6182
  * See {@link Span.startSpan} for more details.
5170
6183
  */
5171
6184
  async export() {
5172
- return new (0, _core.SpanComponentsV3)({
6185
+ return new SpanComponentsV3({
5173
6186
  object_type: this.parentObjectType(),
5174
6187
  object_id: await this.id
5175
6188
  }).toStr();
@@ -5256,7 +6269,7 @@ var SpanImpl = (_class11 = class _SpanImpl {
5256
6269
  this.parentComputeObjectMetadataArgs = args.parentComputeObjectMetadataArgs;
5257
6270
  this.propagatedEvent = args.propagatedEvent;
5258
6271
  if (this.propagatedEvent) {
5259
- _core.mergeDicts.call(void 0, rawEvent, this.propagatedEvent);
6272
+ mergeDicts(rawEvent, this.propagatedEvent);
5260
6273
  }
5261
6274
  const { id: eventId, ...event } = rawEvent;
5262
6275
  const callerLocation = isomorph_default.getCallerLocation();
@@ -5333,12 +6346,12 @@ var SpanImpl = (_class11 = class _SpanImpl {
5333
6346
  root_span_id: this._rootSpanId,
5334
6347
  span_parents: this._spanParents,
5335
6348
  ...serializableInternalData,
5336
- [_core.IS_MERGE_FIELD]: this.isMerge
6349
+ [IS_MERGE_FIELD]: this.isMerge
5337
6350
  });
5338
- if (_optionalChain([partialRecord, 'access', _49 => _49.metrics, 'optionalAccess', _50 => _50.end])) {
5339
- this.loggedEndTime = _optionalChain([partialRecord, 'access', _51 => _51.metrics, 'optionalAccess', _52 => _52.end]);
6351
+ if (_optionalChain([partialRecord, 'access', _60 => _60.metrics, 'optionalAccess', _61 => _61.end])) {
6352
+ this.loggedEndTime = _optionalChain([partialRecord, 'access', _62 => _62.metrics, 'optionalAccess', _63 => _63.end]);
5340
6353
  }
5341
- if ((_nullishCoalesce(partialRecord.tags, () => ( []))).length > 0 && _optionalChain([this, 'access', _53 => _53._spanParents, 'optionalAccess', _54 => _54.length])) {
6354
+ if ((_nullishCoalesce(partialRecord.tags, () => ( []))).length > 0 && _optionalChain([this, 'access', _64 => _64._spanParents, 'optionalAccess', _65 => _65.length])) {
5342
6355
  throw new Error("Tags can only be logged to the root span");
5343
6356
  }
5344
6357
  const computeRecord = async () => ({
@@ -5351,7 +6364,7 @@ var SpanImpl = (_class11 = class _SpanImpl {
5351
6364
  ])
5352
6365
  )
5353
6366
  ),
5354
- ...new (0, _core.SpanComponentsV3)({
6367
+ ...new SpanComponentsV3({
5355
6368
  object_type: this.parentObjectType,
5356
6369
  object_id: await this.parentObjectId.get()
5357
6370
  }).objectIdFields()
@@ -5383,18 +6396,18 @@ var SpanImpl = (_class11 = class _SpanImpl {
5383
6396
  );
5384
6397
  }
5385
6398
  startSpan(args) {
5386
- const parentSpanIds = _optionalChain([args, 'optionalAccess', _55 => _55.parent]) ? void 0 : { spanId: this._spanId, rootSpanId: this._rootSpanId };
6399
+ const parentSpanIds = _optionalChain([args, 'optionalAccess', _66 => _66.parent]) ? void 0 : { spanId: this._spanId, rootSpanId: this._rootSpanId };
5387
6400
  return new _SpanImpl({
5388
6401
  state: this._state,
5389
6402
  ...args,
5390
6403
  ...startSpanParentArgs({
5391
6404
  state: this._state,
5392
- parent: _optionalChain([args, 'optionalAccess', _56 => _56.parent]),
6405
+ parent: _optionalChain([args, 'optionalAccess', _67 => _67.parent]),
5393
6406
  parentObjectType: this.parentObjectType,
5394
6407
  parentObjectId: this.parentObjectId,
5395
6408
  parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
5396
6409
  parentSpanIds,
5397
- propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _57 => _57.propagatedEvent]), () => ( this.propagatedEvent))
6410
+ propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _68 => _68.propagatedEvent]), () => ( this.propagatedEvent))
5398
6411
  })
5399
6412
  });
5400
6413
  }
@@ -5408,12 +6421,12 @@ var SpanImpl = (_class11 = class _SpanImpl {
5408
6421
  ...args,
5409
6422
  ...startSpanParentArgs({
5410
6423
  state: this._state,
5411
- parent: _optionalChain([args, 'optionalAccess', _58 => _58.parent]),
6424
+ parent: _optionalChain([args, 'optionalAccess', _69 => _69.parent]),
5412
6425
  parentObjectType: this.parentObjectType,
5413
6426
  parentObjectId: this.parentObjectId,
5414
6427
  parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
5415
6428
  parentSpanIds,
5416
- propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _59 => _59.propagatedEvent]), () => ( this.propagatedEvent))
6429
+ propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _70 => _70.propagatedEvent]), () => ( this.propagatedEvent))
5417
6430
  }),
5418
6431
  spanId
5419
6432
  });
@@ -5422,7 +6435,7 @@ var SpanImpl = (_class11 = class _SpanImpl {
5422
6435
  let endTime;
5423
6436
  let internalData = {};
5424
6437
  if (!this.loggedEndTime) {
5425
- endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _60 => _60.endTime]), () => ( getCurrentUnixTimestamp()));
6438
+ endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _71 => _71.endTime]), () => ( getCurrentUnixTimestamp()));
5426
6439
  internalData = { metrics: { end: endTime } };
5427
6440
  } else {
5428
6441
  endTime = this.loggedEndTime;
@@ -5431,7 +6444,7 @@ var SpanImpl = (_class11 = class _SpanImpl {
5431
6444
  return endTime;
5432
6445
  }
5433
6446
  async export() {
5434
- return new (0, _core.SpanComponentsV3)({
6447
+ return new SpanComponentsV3({
5435
6448
  object_type: this.parentObjectType,
5436
6449
  ...this.parentComputeObjectMetadataArgs && !this.parentObjectId.hasSucceeded ? { compute_object_metadata_args: this.parentComputeObjectMetadataArgs } : { object_id: await this.parentObjectId.get() },
5437
6450
  row_id: this.id,
@@ -5464,9 +6477,9 @@ var SpanImpl = (_class11 = class _SpanImpl {
5464
6477
  const baseUrl = `${appUrl}/app/${orgName}`;
5465
6478
  const args = this.parentComputeObjectMetadataArgs;
5466
6479
  switch (this.parentObjectType) {
5467
- case _core.SpanObjectTypeV3.PROJECT_LOGS: {
5468
- const projectID = _optionalChain([args, 'optionalAccess', _61 => _61.project_id]) || this.parentObjectId.getSync().value;
5469
- const projectName = _optionalChain([args, 'optionalAccess', _62 => _62.project_name]);
6480
+ case 2 /* PROJECT_LOGS */: {
6481
+ const projectID = _optionalChain([args, 'optionalAccess', _72 => _72.project_id]) || this.parentObjectId.getSync().value;
6482
+ const projectName = _optionalChain([args, 'optionalAccess', _73 => _73.project_name]);
5470
6483
  if (projectID) {
5471
6484
  return `${baseUrl}/object?object_type=project_logs&object_id=${projectID}&id=${this._id}`;
5472
6485
  } else if (projectName) {
@@ -5475,15 +6488,15 @@ var SpanImpl = (_class11 = class _SpanImpl {
5475
6488
  return getErrPermlink("provide-project-name-or-id");
5476
6489
  }
5477
6490
  }
5478
- case _core.SpanObjectTypeV3.EXPERIMENT: {
5479
- const expID = _optionalChain([args, 'optionalAccess', _63 => _63.experiment_id]) || _optionalChain([this, 'access', _64 => _64.parentObjectId, 'optionalAccess', _65 => _65.getSync, 'call', _66 => _66(), 'optionalAccess', _67 => _67.value]);
6491
+ case 1 /* EXPERIMENT */: {
6492
+ const expID = _optionalChain([args, 'optionalAccess', _74 => _74.experiment_id]) || _optionalChain([this, 'access', _75 => _75.parentObjectId, 'optionalAccess', _76 => _76.getSync, 'call', _77 => _77(), 'optionalAccess', _78 => _78.value]);
5480
6493
  if (!expID) {
5481
6494
  return getErrPermlink("provide-experiment-id");
5482
6495
  } else {
5483
6496
  return `${baseUrl}/object?object_type=experiment&object_id=${expID}&id=${this._id}`;
5484
6497
  }
5485
6498
  }
5486
- case _core.SpanObjectTypeV3.PLAYGROUND_LOGS: {
6499
+ case 3 /* PLAYGROUND_LOGS */: {
5487
6500
  return NOOP_SPAN_PERMALINK;
5488
6501
  }
5489
6502
  default: {
@@ -5502,6 +6515,20 @@ var SpanImpl = (_class11 = class _SpanImpl {
5502
6515
  state() {
5503
6516
  return this._state;
5504
6517
  }
6518
+ // Custom inspect for Node.js console.log
6519
+ [Symbol.for("nodejs.util.inspect.custom")]() {
6520
+ return `SpanImpl {
6521
+ kind: '${this.kind}',
6522
+ id: '${this.id}',
6523
+ spanId: '${this.spanId}',
6524
+ rootSpanId: '${this.rootSpanId}',
6525
+ spanParents: ${JSON.stringify(this.spanParents)}
6526
+ }`;
6527
+ }
6528
+ // Custom toString
6529
+ toString() {
6530
+ return `SpanImpl(id=${this.id}, spanId=${this.spanId})`;
6531
+ }
5505
6532
  }, _class11);
5506
6533
  function splitLoggingData({
5507
6534
  event,
@@ -5509,8 +6536,8 @@ function splitLoggingData({
5509
6536
  }) {
5510
6537
  const sanitized = validateAndSanitizeExperimentLogPartialArgs(_nullishCoalesce(event, () => ( {})));
5511
6538
  const sanitizedAndInternalData = {};
5512
- _core.mergeDicts.call(void 0, sanitizedAndInternalData, internalData || {});
5513
- _core.mergeDicts.call(void 0, sanitizedAndInternalData, sanitized);
6539
+ mergeDicts(sanitizedAndInternalData, internalData || {});
6540
+ mergeDicts(sanitizedAndInternalData, sanitized);
5514
6541
  const serializableInternalData = {};
5515
6542
  const lazyInternalData = {};
5516
6543
  for (const [key, value] of Object.entries(sanitizedAndInternalData)) {
@@ -5535,7 +6562,7 @@ function splitLoggingData({
5535
6562
  }
5536
6563
  var Dataset2 = (_class12 = class extends ObjectFetcher {
5537
6564
  constructor(state, lazyMetadata, pinnedVersion, legacy, _internal_btql) {
5538
- const isLegacyDataset = _nullishCoalesce(legacy, () => ( _core.DEFAULT_IS_LEGACY_DATASET));
6565
+ const isLegacyDataset = _nullishCoalesce(legacy, () => ( DEFAULT_IS_LEGACY_DATASET));
5539
6566
  if (isLegacyDataset) {
5540
6567
  console.warn(
5541
6568
  `Records will be fetched from this dataset in the legacy format, with the "expected" field renamed to "output". Please update your code to use "expected", and use \`braintrust.initDataset()\` with \`{ useOutput: false }\`, which will become the default in a future version of Braintrust.`
@@ -5546,7 +6573,7 @@ var Dataset2 = (_class12 = class extends ObjectFetcher {
5546
6573
  pinnedVersion,
5547
6574
  (r) => (
5548
6575
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
5549
- _core.ensureDatasetRecord.call(void 0,
6576
+ ensureDatasetRecord(
5550
6577
  enrichAttachments(r, this.state),
5551
6578
  isLegacyDataset
5552
6579
  )
@@ -5622,7 +6649,7 @@ var Dataset2 = (_class12 = class extends ObjectFetcher {
5622
6649
  //if we're merging/updating an event we will not add this ts
5623
6650
  metadata,
5624
6651
  ...!!isMerge ? {
5625
- [_core.IS_MERGE_FIELD]: true
6652
+ [IS_MERGE_FIELD]: true
5626
6653
  } : {}
5627
6654
  };
5628
6655
  return args;
@@ -5783,7 +6810,7 @@ function renderMessage(render, message) {
5783
6810
  case "text":
5784
6811
  return { ...c, text: render(c.text) };
5785
6812
  case "image_url":
5786
- if (_core.isObject.call(void 0, c.image_url.url)) {
6813
+ if (isObject(c.image_url.url)) {
5787
6814
  throw new Error(
5788
6815
  "Attachments must be replaced with URLs before calling `build()`"
5789
6816
  );
@@ -5842,9 +6869,9 @@ function renderTemplatedObject(obj, args, options) {
5842
6869
  }
5843
6870
  }
5844
6871
  });
5845
- } else if (_core.isArray.call(void 0, obj)) {
6872
+ } else if (isArray(obj)) {
5846
6873
  return obj.map((item) => renderTemplatedObject(item, args, options));
5847
- } else if (_core.isObject.call(void 0, obj)) {
6874
+ } else if (isObject(obj)) {
5848
6875
  return Object.fromEntries(
5849
6876
  Object.entries(obj).map(([key, value]) => [
5850
6877
  key,
@@ -5902,13 +6929,13 @@ var Prompt2 = (_class13 = class _Prompt {
5902
6929
  return "slug" in this.metadata ? this.metadata.slug : this.metadata.id;
5903
6930
  }
5904
6931
  get prompt() {
5905
- return _optionalChain([this, 'access', _68 => _68.getParsedPromptData, 'call', _69 => _69(), 'optionalAccess', _70 => _70.prompt]);
6932
+ return _optionalChain([this, 'access', _79 => _79.getParsedPromptData, 'call', _80 => _80(), 'optionalAccess', _81 => _81.prompt]);
5906
6933
  }
5907
6934
  get version() {
5908
- return this.metadata[_core.TRANSACTION_ID_FIELD];
6935
+ return this.metadata[TRANSACTION_ID_FIELD];
5909
6936
  }
5910
6937
  get options() {
5911
- return _optionalChain([this, 'access', _71 => _71.getParsedPromptData, 'call', _72 => _72(), 'optionalAccess', _73 => _73.options]) || {};
6938
+ return _optionalChain([this, 'access', _82 => _82.getParsedPromptData, 'call', _83 => _83(), 'optionalAccess', _84 => _84.options]) || {};
5912
6939
  }
5913
6940
  get promptData() {
5914
6941
  return this.getParsedPromptData();
@@ -6059,7 +7086,7 @@ var Prompt2 = (_class13 = class _Prompt {
6059
7086
  return {
6060
7087
  type: "chat",
6061
7088
  messages,
6062
- ..._optionalChain([prompt, 'access', _74 => _74.tools, 'optionalAccess', _75 => _75.trim, 'call', _76 => _76()]) ? {
7089
+ ..._optionalChain([prompt, 'access', _85 => _85.tools, 'optionalAccess', _86 => _86.trim, 'call', _87 => _87()]) ? {
6063
7090
  tools: render(prompt.tools)
6064
7091
  } : void 0
6065
7092
  };
@@ -6169,9 +7196,9 @@ async function getPromptVersions(projectId, promptId) {
6169
7196
  );
6170
7197
  }
6171
7198
  const result = await response.json();
6172
- return _optionalChain([result, 'access', _77 => _77.data, 'optionalAccess', _78 => _78.filter, 'call', _79 => _79(
6173
- (entry) => ["upsert", "merge"].includes(_optionalChain([entry, 'access', _80 => _80.audit_data, 'optionalAccess', _81 => _81.action]))
6174
- ), 'access', _82 => _82.map, 'call', _83 => _83((entry) => _core.prettifyXact.call(void 0, entry._xact_id))]) || [];
7199
+ return _optionalChain([result, 'access', _88 => _88.data, 'optionalAccess', _89 => _89.filter, 'call', _90 => _90(
7200
+ (entry) => ["upsert", "merge"].includes(_optionalChain([entry, 'access', _91 => _91.audit_data, 'optionalAccess', _92 => _92.action]))
7201
+ ), 'access', _93 => _93.map, 'call', _94 => _94((entry) => prettifyXact(entry._xact_id))]) || [];
6175
7202
  }
6176
7203
  var _exportsForTestingOnly = {
6177
7204
  extractAttachments,
@@ -6196,7 +7223,7 @@ function configureBrowser() {
6196
7223
  if (typeof AsyncLocalStorage !== "undefined") {
6197
7224
  isomorph_default.newAsyncLocalStorage = () => new AsyncLocalStorage();
6198
7225
  }
6199
- } catch (e3) {
7226
+ } catch (e5) {
6200
7227
  }
6201
7228
  isomorph_default.getEnv = (name) => {
6202
7229
  if (typeof process === "undefined" || typeof process.env === "undefined") {
@@ -6251,6 +7278,7 @@ __export(exports_browser_exports, {
6251
7278
  currentExperiment: () => currentExperiment,
6252
7279
  currentLogger: () => currentLogger,
6253
7280
  currentSpan: () => currentSpan,
7281
+ deepCopyEvent: () => deepCopyEvent,
6254
7282
  deserializePlainStringAsJSON: () => deserializePlainStringAsJSON,
6255
7283
  devNullWritableStream: () => devNullWritableStream,
6256
7284
  evaluatorDefinitionSchema: () => evaluatorDefinitionSchema,
@@ -6380,12 +7408,7 @@ function initFunction({
6380
7408
  return f;
6381
7409
  }
6382
7410
 
6383
- // src/wrappers/oai.ts
6384
-
6385
-
6386
-
6387
7411
  // src/wrappers/oai_responses.ts
6388
-
6389
7412
  function responsesProxy(openai) {
6390
7413
  if (!openai.responses) {
6391
7414
  return openai;
@@ -6434,8 +7457,8 @@ function parseSpanFromResponseCreateParams(params) {
6434
7457
  }
6435
7458
  function parseEventFromResponseCreateResult(result) {
6436
7459
  const data = {};
6437
- if (_optionalChain([result, 'optionalAccess', _84 => _84.output]) !== void 0) {
6438
- data.output = result.output;
7460
+ if (_optionalChain([result, 'optionalAccess', _95 => _95.output]) !== void 0) {
7461
+ data.output = processImagesInOutput(result.output);
6439
7462
  }
6440
7463
  if (result) {
6441
7464
  const { output, usage, ...metadata } = result;
@@ -6443,9 +7466,38 @@ function parseEventFromResponseCreateResult(result) {
6443
7466
  data.metadata = metadata;
6444
7467
  }
6445
7468
  }
6446
- data.metrics = parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _85 => _85.usage]));
7469
+ data.metrics = parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _96 => _96.usage]));
6447
7470
  return data;
6448
7471
  }
7472
+ function processImagesInOutput(output) {
7473
+ if (Array.isArray(output)) {
7474
+ return output.map(processImagesInOutput);
7475
+ }
7476
+ if (isObject(output)) {
7477
+ if (output.type === "image_generation_call" && output.result && typeof output.result === "string") {
7478
+ const fileExtension = output.output_format || "png";
7479
+ const contentType = `image/${fileExtension}`;
7480
+ const baseFilename = output.revised_prompt && typeof output.revised_prompt === "string" ? output.revised_prompt.slice(0, 50).replace(/[^a-zA-Z0-9]/g, "_") : "generated_image";
7481
+ const filename = `${baseFilename}.${fileExtension}`;
7482
+ const binaryString = atob(output.result);
7483
+ const bytes = new Uint8Array(binaryString.length);
7484
+ for (let i = 0; i < binaryString.length; i++) {
7485
+ bytes[i] = binaryString.charCodeAt(i);
7486
+ }
7487
+ const blob = new Blob([bytes], { type: contentType });
7488
+ const attachment = new Attachment({
7489
+ data: blob,
7490
+ filename,
7491
+ contentType
7492
+ });
7493
+ return {
7494
+ ...output,
7495
+ result: attachment
7496
+ };
7497
+ }
7498
+ }
7499
+ return output;
7500
+ }
6449
7501
  function parseSpanFromResponseParseParams(params) {
6450
7502
  const spanArgs = {
6451
7503
  name: "openai.responses.parse",
@@ -6468,8 +7520,8 @@ function parseSpanFromResponseParseParams(params) {
6468
7520
  }
6469
7521
  function parseEventFromResponseParseResult(result) {
6470
7522
  const data = {};
6471
- if (_optionalChain([result, 'optionalAccess', _86 => _86.output]) !== void 0) {
6472
- data.output = result.output;
7523
+ if (_optionalChain([result, 'optionalAccess', _97 => _97.output]) !== void 0) {
7524
+ data.output = processImagesInOutput(result.output);
6473
7525
  }
6474
7526
  if (result) {
6475
7527
  const { output, usage, ...metadata } = result;
@@ -6477,7 +7529,7 @@ function parseEventFromResponseParseResult(result) {
6477
7529
  data.metadata = metadata;
6478
7530
  }
6479
7531
  }
6480
- data.metrics = parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _87 => _87.usage]));
7532
+ data.metrics = parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _98 => _98.usage]));
6481
7533
  return data;
6482
7534
  }
6483
7535
  function traceResponseCreateStream(stream, timedSpan) {
@@ -6494,7 +7546,7 @@ function traceResponseCreateStream(stream, timedSpan) {
6494
7546
  return result;
6495
7547
  }
6496
7548
  const item = result.value;
6497
- if (!item || !_optionalChain([item, 'optionalAccess', _88 => _88.type]) || !_optionalChain([item, 'optionalAccess', _89 => _89.response])) {
7549
+ if (!item || !_optionalChain([item, 'optionalAccess', _99 => _99.type]) || !_optionalChain([item, 'optionalAccess', _100 => _100.response])) {
6498
7550
  return result;
6499
7551
  }
6500
7552
  const event = parseLogFromItem(item);
@@ -6505,15 +7557,15 @@ function traceResponseCreateStream(stream, timedSpan) {
6505
7557
  };
6506
7558
  }
6507
7559
  function parseLogFromItem(item) {
6508
- if (!item || !_optionalChain([item, 'optionalAccess', _90 => _90.type]) || !_optionalChain([item, 'optionalAccess', _91 => _91.response])) {
7560
+ if (!item || !_optionalChain([item, 'optionalAccess', _101 => _101.type]) || !_optionalChain([item, 'optionalAccess', _102 => _102.response])) {
6509
7561
  return {};
6510
7562
  }
6511
7563
  const response = item.response;
6512
7564
  switch (item.type) {
6513
7565
  case "response.completed":
6514
7566
  const data = {};
6515
- if (_optionalChain([response, 'optionalAccess', _92 => _92.output]) !== void 0) {
6516
- data.output = response.output;
7567
+ if (_optionalChain([response, 'optionalAccess', _103 => _103.output]) !== void 0) {
7568
+ data.output = processImagesInOutput(response.output);
6517
7569
  }
6518
7570
  if (response) {
6519
7571
  const { usage, output, ...metadata } = response;
@@ -6521,7 +7573,7 @@ function parseLogFromItem(item) {
6521
7573
  data.metadata = metadata;
6522
7574
  }
6523
7575
  }
6524
- data.metrics = parseMetricsFromUsage(_optionalChain([response, 'optionalAccess', _93 => _93.usage]));
7576
+ data.metrics = parseMetricsFromUsage(_optionalChain([response, 'optionalAccess', _104 => _104.usage]));
6525
7577
  return data;
6526
7578
  default:
6527
7579
  return {};
@@ -6583,7 +7635,7 @@ function parseMetricsFromUsage(usage) {
6583
7635
  const metricName = TOKEN_NAME_MAP[oai_name] || oai_name;
6584
7636
  metrics[metricName] = value;
6585
7637
  } else if (oai_name.endsWith("_tokens_details")) {
6586
- if (!_core.isObject.call(void 0, value)) {
7638
+ if (!isObject(value)) {
6587
7639
  continue;
6588
7640
  }
6589
7641
  const rawPrefix = oai_name.slice(0, -"_tokens_details".length);
@@ -6705,8 +7757,8 @@ function wrapOpenAIv4(openai) {
6705
7757
  const embeddingProxy = createEndpointProxy(openai.embeddings, wrapEmbeddings);
6706
7758
  const moderationProxy = createEndpointProxy(openai.moderations, wrapModerations);
6707
7759
  let betaProxy;
6708
- if (_optionalChain([openai, 'access', _94 => _94.beta, 'optionalAccess', _95 => _95.chat, 'optionalAccess', _96 => _96.completions, 'optionalAccess', _97 => _97.stream])) {
6709
- const betaChatCompletionProxy = new Proxy(_optionalChain([openai, 'optionalAccess', _98 => _98.beta, 'optionalAccess', _99 => _99.chat, 'access', _100 => _100.completions]), {
7760
+ if (_optionalChain([openai, 'access', _105 => _105.beta, 'optionalAccess', _106 => _106.chat, 'optionalAccess', _107 => _107.completions, 'optionalAccess', _108 => _108.stream])) {
7761
+ const betaChatCompletionProxy = new Proxy(_optionalChain([openai, 'optionalAccess', _109 => _109.beta, 'optionalAccess', _110 => _110.chat, 'access', _111 => _111.completions]), {
6710
7762
  get(target, name, receiver) {
6711
7763
  const baseVal = Reflect.get(target, name, receiver);
6712
7764
  if (name === "parse") {
@@ -6754,7 +7806,7 @@ function wrapOpenAIv4(openai) {
6754
7806
  });
6755
7807
  }
6756
7808
  function logCompletionResponse(startTime, response, span) {
6757
- const metrics = parseMetricsFromUsage(_optionalChain([response, 'optionalAccess', _101 => _101.usage]));
7809
+ const metrics = parseMetricsFromUsage(_optionalChain([response, 'optionalAccess', _112 => _112.usage]));
6758
7810
  metrics.time_to_first_token = getCurrentUnixTimestamp() - startTime;
6759
7811
  span.log({
6760
7812
  output: response.choices,
@@ -6765,11 +7817,11 @@ function wrapBetaChatCompletionParse(completion) {
6765
7817
  return async (allParams) => {
6766
7818
  const { span_info: _, ...params } = allParams;
6767
7819
  const span = startSpan(
6768
- _core.mergeDicts.call(void 0,
7820
+ mergeDicts(
6769
7821
  {
6770
7822
  name: "Chat Completion",
6771
7823
  spanAttributes: {
6772
- type: _core.SpanTypeAttribute.LLM
7824
+ type: "llm" /* LLM */
6773
7825
  }
6774
7826
  },
6775
7827
  parseChatCompletionParams(allParams)
@@ -6789,11 +7841,11 @@ function wrapBetaChatCompletionStream(completion) {
6789
7841
  return (allParams) => {
6790
7842
  const { span_info: _, ...params } = allParams;
6791
7843
  const span = startSpan(
6792
- _core.mergeDicts.call(void 0,
7844
+ mergeDicts(
6793
7845
  {
6794
7846
  name: "Chat Completion",
6795
7847
  spanAttributes: {
6796
- type: _core.SpanTypeAttribute.LLM
7848
+ type: "llm" /* LLM */
6797
7849
  }
6798
7850
  },
6799
7851
  parseChatCompletionParams(allParams)
@@ -6852,15 +7904,16 @@ function wrapChatCompletion(completion) {
6852
7904
  return (allParams, options) => {
6853
7905
  const { span_info: _, ...params } = allParams;
6854
7906
  let executionPromise = null;
6855
- const executeWrapped = () => {
7907
+ let dataPromise = null;
7908
+ const ensureExecuted = () => {
6856
7909
  if (!executionPromise) {
6857
7910
  executionPromise = (async () => {
6858
7911
  const span = startSpan(
6859
- _core.mergeDicts.call(void 0,
7912
+ mergeDicts(
6860
7913
  {
6861
7914
  name: "Chat Completion",
6862
7915
  spanAttributes: {
6863
- type: _core.SpanTypeAttribute.LLM
7916
+ type: "llm" /* LLM */
6864
7917
  }
6865
7918
  },
6866
7919
  parseChatCompletionParams(allParams)
@@ -6910,17 +7963,19 @@ function wrapChatCompletion(completion) {
6910
7963
  }
6911
7964
  return executionPromise;
6912
7965
  };
6913
- const dataPromise = executeWrapped().then((result) => result.data);
6914
- return new Proxy(dataPromise, {
7966
+ return new Proxy({}, {
6915
7967
  get(target, prop, receiver) {
6916
7968
  if (prop === "withResponse") {
6917
- return executeWrapped;
7969
+ return () => ensureExecuted();
6918
7970
  }
6919
- const value = Reflect.get(target, prop, receiver);
6920
- if (typeof value === "function") {
6921
- return value.bind(target);
7971
+ if (prop === "then" || prop === "catch" || prop === "finally" || prop in Promise.prototype) {
7972
+ if (!dataPromise) {
7973
+ dataPromise = ensureExecuted().then((result) => result.data);
7974
+ }
7975
+ const value = Reflect.get(dataPromise, prop, receiver);
7976
+ return typeof value === "function" ? value.bind(dataPromise) : value;
6922
7977
  }
6923
- return value;
7978
+ return Reflect.get(target, prop, receiver);
6924
7979
  }
6925
7980
  });
6926
7981
  };
@@ -6937,7 +7992,7 @@ function parseBaseParams(allParams, inputField) {
6937
7992
  const input = params[inputField];
6938
7993
  const paramsRest = { ...params, provider: "openai" };
6939
7994
  delete paramsRest[inputField];
6940
- return _core.mergeDicts.call(void 0, ret, { event: { input, metadata: paramsRest } });
7995
+ return mergeDicts(ret, { event: { input, metadata: paramsRest } });
6941
7996
  }
6942
7997
  function createApiWrapper(name, create, processResponse, parseParams) {
6943
7998
  return async (allParams, options) => {
@@ -6952,11 +8007,11 @@ function createApiWrapper(name, create, processResponse, parseParams) {
6952
8007
  processResponse(result, span);
6953
8008
  return result;
6954
8009
  },
6955
- _core.mergeDicts.call(void 0,
8010
+ mergeDicts(
6956
8011
  {
6957
8012
  name,
6958
8013
  spanAttributes: {
6959
- type: _core.SpanTypeAttribute.LLM
8014
+ type: "llm" /* LLM */
6960
8015
  }
6961
8016
  },
6962
8017
  parseParams(allParams)
@@ -6981,7 +8036,7 @@ function parseChatCompletionParams(params) {
6981
8036
  function processEmbeddingResponse(result, span) {
6982
8037
  span.log({
6983
8038
  output: { embedding_length: result.data[0].embedding.length },
6984
- metrics: parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _102 => _102.usage]))
8039
+ metrics: parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _113 => _113.usage]))
6985
8040
  });
6986
8041
  }
6987
8042
  function processModerationResponse(result, span) {
@@ -7011,10 +8066,10 @@ function postprocessStreamingResults(allResults) {
7011
8066
  if (result.usage) {
7012
8067
  metrics = {
7013
8068
  ...metrics,
7014
- ...parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _103 => _103.usage]))
8069
+ ...parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _114 => _114.usage]))
7015
8070
  };
7016
8071
  }
7017
- const delta = _optionalChain([result, 'access', _104 => _104.choices, 'optionalAccess', _105 => _105[0], 'optionalAccess', _106 => _106.delta]);
8072
+ const delta = _optionalChain([result, 'access', _115 => _115.choices, 'optionalAccess', _116 => _116[0], 'optionalAccess', _117 => _117.delta]);
7018
8073
  if (!delta) {
7019
8074
  continue;
7020
8075
  }
@@ -7096,43 +8151,43 @@ var WrapperStream = class {
7096
8151
 
7097
8152
  // dev/types.ts
7098
8153
 
7099
- var evalBodySchema = _zod.z.object({
7100
- name: _zod.z.string(),
7101
- parameters: _zod.z.record(_zod.z.string(), _zod.z.unknown()).nullish(),
8154
+ var evalBodySchema = _v3.z.object({
8155
+ name: _v3.z.string(),
8156
+ parameters: _v3.z.record(_v3.z.string(), _v3.z.unknown()).nullish(),
7102
8157
  data: RunEval.shape.data,
7103
- scores: _zod.z.array(
7104
- _zod.z.object({
8158
+ scores: _v3.z.array(
8159
+ _v3.z.object({
7105
8160
  function_id: FunctionId,
7106
- name: _zod.z.string()
8161
+ name: _v3.z.string()
7107
8162
  })
7108
8163
  ).nullish(),
7109
- experiment_name: _zod.z.string().nullish(),
7110
- project_id: _zod.z.string().nullish(),
8164
+ experiment_name: _v3.z.string().nullish(),
8165
+ project_id: _v3.z.string().nullish(),
7111
8166
  parent: InvokeParent.optional(),
7112
- stream: _zod.z.boolean().optional()
8167
+ stream: _v3.z.boolean().optional()
7113
8168
  });
7114
- var evalParametersSerializedSchema = _zod.z.record(
7115
- _zod.z.string(),
7116
- _zod.z.union([
7117
- _zod.z.object({
7118
- type: _zod.z.literal("prompt"),
8169
+ var evalParametersSerializedSchema = _v3.z.record(
8170
+ _v3.z.string(),
8171
+ _v3.z.union([
8172
+ _v3.z.object({
8173
+ type: _v3.z.literal("prompt"),
7119
8174
  default: PromptData.optional(),
7120
- description: _zod.z.string().optional()
8175
+ description: _v3.z.string().optional()
7121
8176
  }),
7122
- _zod.z.object({
7123
- type: _zod.z.literal("data"),
7124
- schema: _zod.z.record(_zod.z.unknown()),
8177
+ _v3.z.object({
8178
+ type: _v3.z.literal("data"),
8179
+ schema: _v3.z.record(_v3.z.unknown()),
7125
8180
  // JSON Schema
7126
- default: _zod.z.unknown().optional(),
7127
- description: _zod.z.string().optional()
8181
+ default: _v3.z.unknown().optional(),
8182
+ description: _v3.z.string().optional()
7128
8183
  })
7129
8184
  ])
7130
8185
  );
7131
- var evaluatorDefinitionSchema = _zod.z.object({
8186
+ var evaluatorDefinitionSchema = _v3.z.object({
7132
8187
  parameters: evalParametersSerializedSchema.optional()
7133
8188
  });
7134
- var evaluatorDefinitionsSchema = _zod.z.record(
7135
- _zod.z.string(),
8189
+ var evaluatorDefinitionsSchema = _v3.z.record(
8190
+ _v3.z.string(),
7136
8191
  evaluatorDefinitionSchema
7137
8192
  );
7138
8193
 
@@ -7210,4 +8265,5 @@ var browser_default = exports_browser_exports;
7210
8265
 
7211
8266
 
7212
8267
 
7213
- exports.Attachment = Attachment; exports.BaseAttachment = BaseAttachment; exports.BraintrustState = BraintrustState; exports.BraintrustStream = BraintrustStream; exports.Dataset = Dataset2; exports.ERR_PERMALINK = ERR_PERMALINK; exports.Experiment = Experiment2; exports.ExternalAttachment = ExternalAttachment; exports.FailedHTTPResponse = FailedHTTPResponse; exports.INTERNAL_BTQL_LIMIT = INTERNAL_BTQL_LIMIT; exports.LEGACY_CACHED_HEADER = LEGACY_CACHED_HEADER; exports.LazyValue = LazyValue; exports.Logger = Logger; exports.NOOP_SPAN = NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = NOOP_SPAN_PERMALINK; exports.NoopSpan = NoopSpan; exports.Prompt = Prompt2; exports.ReadonlyAttachment = ReadonlyAttachment; exports.ReadonlyExperiment = ReadonlyExperiment; exports.SpanImpl = SpanImpl; exports.TestBackgroundLogger = TestBackgroundLogger; exports.X_CACHED_HEADER = X_CACHED_HEADER; exports._exportsForTestingOnly = _exportsForTestingOnly; exports._internalGetGlobalState = _internalGetGlobalState; exports._internalSetInitialState = _internalSetInitialState; exports.braintrustStreamChunkSchema = braintrustStreamChunkSchema; exports.createFinalValuePassThroughStream = createFinalValuePassThroughStream; exports.currentExperiment = currentExperiment; exports.currentLogger = currentLogger; exports.currentSpan = currentSpan; exports.default = browser_default; exports.deserializePlainStringAsJSON = deserializePlainStringAsJSON; exports.devNullWritableStream = devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.flush = flush; exports.getPromptVersions = getPromptVersions; exports.getSpanParentObject = getSpanParentObject; exports.init = init; exports.initDataset = initDataset; exports.initExperiment = initExperiment; exports.initFunction = initFunction; exports.initLogger = initLogger; exports.invoke = invoke; exports.loadPrompt = loadPrompt; exports.log = log; exports.logError = logError; exports.login = login; exports.loginToState = loginToState; exports.newId = newId; exports.parseCachedHeader = parseCachedHeader; exports.permalink = permalink; exports.renderMessage = renderMessage; exports.renderPromptParams = renderPromptParams; exports.setFetch = setFetch; exports.setMaskingFunction = setMaskingFunction; exports.spanComponentsToObjectId = spanComponentsToObjectId; exports.startSpan = startSpan; exports.summarize = summarize; exports.traceable = traceable; exports.traced = traced; exports.updateSpan = updateSpan; exports.withCurrent = withCurrent; exports.withDataset = withDataset; exports.withExperiment = withExperiment; exports.withLogger = withLogger; exports.withParent = withParent; exports.wrapOpenAI = wrapOpenAI; exports.wrapOpenAIv4 = wrapOpenAIv4; exports.wrapTraced = wrapTraced;
8268
+
8269
+ exports.Attachment = Attachment; exports.BaseAttachment = BaseAttachment; exports.BraintrustState = BraintrustState; exports.BraintrustStream = BraintrustStream; exports.Dataset = Dataset2; exports.ERR_PERMALINK = ERR_PERMALINK; exports.Experiment = Experiment2; exports.ExternalAttachment = ExternalAttachment; exports.FailedHTTPResponse = FailedHTTPResponse; exports.INTERNAL_BTQL_LIMIT = INTERNAL_BTQL_LIMIT; exports.LEGACY_CACHED_HEADER = LEGACY_CACHED_HEADER; exports.LazyValue = LazyValue; exports.Logger = Logger; exports.NOOP_SPAN = NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = NOOP_SPAN_PERMALINK; exports.NoopSpan = NoopSpan; exports.Prompt = Prompt2; exports.ReadonlyAttachment = ReadonlyAttachment; exports.ReadonlyExperiment = ReadonlyExperiment; exports.SpanImpl = SpanImpl; exports.TestBackgroundLogger = TestBackgroundLogger; exports.X_CACHED_HEADER = X_CACHED_HEADER; exports._exportsForTestingOnly = _exportsForTestingOnly; exports._internalGetGlobalState = _internalGetGlobalState; exports._internalSetInitialState = _internalSetInitialState; exports.braintrustStreamChunkSchema = braintrustStreamChunkSchema; exports.createFinalValuePassThroughStream = createFinalValuePassThroughStream; exports.currentExperiment = currentExperiment; exports.currentLogger = currentLogger; exports.currentSpan = currentSpan; exports.deepCopyEvent = deepCopyEvent; exports.default = browser_default; exports.deserializePlainStringAsJSON = deserializePlainStringAsJSON; exports.devNullWritableStream = devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.flush = flush; exports.getPromptVersions = getPromptVersions; exports.getSpanParentObject = getSpanParentObject; exports.init = init; exports.initDataset = initDataset; exports.initExperiment = initExperiment; exports.initFunction = initFunction; exports.initLogger = initLogger; exports.invoke = invoke; exports.loadPrompt = loadPrompt; exports.log = log; exports.logError = logError; exports.login = login; exports.loginToState = loginToState; exports.newId = newId; exports.parseCachedHeader = parseCachedHeader; exports.permalink = permalink; exports.renderMessage = renderMessage; exports.renderPromptParams = renderPromptParams; exports.setFetch = setFetch; exports.setMaskingFunction = setMaskingFunction; exports.spanComponentsToObjectId = spanComponentsToObjectId; exports.startSpan = startSpan; exports.summarize = summarize; exports.traceable = traceable; exports.traced = traced; exports.updateSpan = updateSpan; exports.withCurrent = withCurrent; exports.withDataset = withDataset; exports.withExperiment = withExperiment; exports.withLogger = withLogger; exports.withParent = withParent; exports.wrapOpenAI = wrapOpenAI; exports.wrapOpenAIv4 = wrapOpenAIv4; exports.wrapTraced = wrapTraced;