braintrust 0.2.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.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";
91
97
 
98
+ // util/span_identifier_v3.ts
92
99
 
93
100
 
101
+ // util/span_identifier_v2.ts
94
102
 
95
103
 
104
+ // util/span_identifier_v1.ts
96
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
+ };
97
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
+ };
458
+
459
+ // util/span_identifier_v3.ts
98
460
 
99
461
 
462
+ // util/bytes.ts
463
+ function concatUint8Arrays(...arrays) {
464
+ const totalLength = arrays.reduce((acc, arr) => acc + arr.length, 0);
465
+ const result = new Uint8Array(totalLength);
466
+ let offset = 0;
467
+ for (const arr of arrays) {
468
+ result.set(arr, offset);
469
+ offset += arr.length;
470
+ }
471
+ return result;
472
+ }
473
+ function uint8ArrayToBase64(uint8Array) {
474
+ let binary = "";
475
+ for (let i = 0; i < uint8Array.length; i++) {
476
+ binary += String.fromCharCode(uint8Array[i]);
477
+ }
478
+ return btoa(binary);
479
+ }
480
+ function base64ToUint8Array(base64) {
481
+ const binary = atob(base64);
482
+ const uint8Array = new Uint8Array(binary.length);
483
+ for (let i = 0; i < binary.length; i++) {
484
+ uint8Array[i] = binary.charCodeAt(i);
485
+ }
486
+ return uint8Array;
487
+ }
488
+ function uint8ArrayToString(uint8Array) {
489
+ const decoder = new TextDecoder("utf-8");
490
+ return decoder.decode(uint8Array);
491
+ }
492
+ function stringToUint8Array(str) {
493
+ const encoder = new TextEncoder();
494
+ return encoder.encode(str);
495
+ }
496
+
497
+ // util/span_identifier_v3.ts
498
+ function tryMakeUuid3(s) {
499
+ try {
500
+ const ret = uuid3.parse(s);
501
+ if (ret.length !== 16) {
502
+ throw new Error();
503
+ }
504
+ return { bytes: new Uint8Array(ret), isUUID: true };
505
+ } catch (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 "";
@@ -2253,8 +3208,8 @@ var BraintrustState = (_class5 = class _BraintrustState {
2253
3208
  setFetch(fetch2) {
2254
3209
  this.loginParams.fetch = fetch2;
2255
3210
  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)]);
3211
+ _optionalChain([this, 'access', _13 => _13._apiConn, 'optionalAccess', _14 => _14.setFetch, 'call', _15 => _15(fetch2)]);
3212
+ _optionalChain([this, 'access', _16 => _16._appConn, 'optionalAccess', _17 => _17.setFetch, 'call', _18 => _18(fetch2)]);
2258
3213
  }
2259
3214
  setMaskingFunction(maskingFunction) {
2260
3215
  this.bgLogger().setMaskingFunction(maskingFunction);
@@ -2335,7 +3290,7 @@ function useTestBackgroundLogger() {
2335
3290
  return logger;
2336
3291
  }
2337
3292
  function clearTestBackgroundLogger() {
2338
- _optionalChain([_internalGetGlobalState, 'call', _9 => _9(), 'optionalAccess', _10 => _10.setOverrideBgLogger, 'call', _11 => _11(null)]);
3293
+ _optionalChain([_internalGetGlobalState, 'call', _19 => _19(), 'optionalAccess', _20 => _20.setOverrideBgLogger, 'call', _21 => _21(null)]);
2339
3294
  }
2340
3295
  function initTestExperiment(experimentName, projectName) {
2341
3296
  setInitialTestState();
@@ -2426,7 +3381,7 @@ var HTTPConnection = class _HTTPConnection {
2426
3381
  }
2427
3382
  async get(path, params = void 0, config) {
2428
3383
  const { headers, ...rest } = config || {};
2429
- const url = new URL(_core._urljoin.call(void 0, this.base_url, path));
3384
+ const url = new URL(_urljoin(this.base_url, path));
2430
3385
  url.search = new URLSearchParams(
2431
3386
  params ? Object.entries(params).filter(([_, v]) => v !== void 0).flatMap(
2432
3387
  ([k, v]) => v !== void 0 ? typeof v === "string" ? [[k, v]] : v.map((x) => [k, x]) : []
@@ -2453,7 +3408,7 @@ var HTTPConnection = class _HTTPConnection {
2453
3408
  const this_base_url = this.base_url;
2454
3409
  const this_headers = this.headers;
2455
3410
  return await checkResponse(
2456
- await this_fetch(_core._urljoin.call(void 0, this_base_url, path), {
3411
+ await this_fetch(_urljoin(this_base_url, path), {
2457
3412
  method: "POST",
2458
3413
  headers: {
2459
3414
  Accept: "application/json",
@@ -2848,8 +3803,8 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
2848
3803
  source: inputSource
2849
3804
  }) {
2850
3805
  const source = _nullishCoalesce(inputSource, () => ( "external"));
2851
- if (!_core.VALID_SOURCES.includes(source)) {
2852
- throw new Error(`source must be one of ${_core.VALID_SOURCES}`);
3806
+ if (!VALID_SOURCES.includes(source)) {
3807
+ throw new Error(`source must be one of ${VALID_SOURCES}`);
2853
3808
  }
2854
3809
  if (isEmpty(scores) && isEmpty(expected) && isEmpty(tags) && isEmpty(comment)) {
2855
3810
  throw new Error(
@@ -2866,7 +3821,7 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
2866
3821
  updateEvent = Object.fromEntries(
2867
3822
  Object.entries(updateEvent).filter(([_, v]) => !isEmpty(v))
2868
3823
  );
2869
- const parentIds = async () => new (0, _core.SpanComponentsV3)({
3824
+ const parentIds = async () => new SpanComponentsV3({
2870
3825
  object_type: parentObjectType,
2871
3826
  object_id: await parentObjectId.get()
2872
3827
  }).objectIdFields();
@@ -2876,9 +3831,9 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
2876
3831
  id,
2877
3832
  ...updateEvent,
2878
3833
  ...await parentIds(),
2879
- [_core.AUDIT_SOURCE_FIELD]: source,
2880
- [_core.AUDIT_METADATA_FIELD]: metadata,
2881
- [_core.IS_MERGE_FIELD]: true
3834
+ [AUDIT_SOURCE_FIELD]: source,
3835
+ [AUDIT_METADATA_FIELD]: metadata,
3836
+ [IS_MERGE_FIELD]: true
2882
3837
  };
2883
3838
  });
2884
3839
  state.bgLogger().log([record]);
@@ -2897,8 +3852,8 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
2897
3852
  text: comment
2898
3853
  },
2899
3854
  ...await parentIds(),
2900
- [_core.AUDIT_SOURCE_FIELD]: source,
2901
- [_core.AUDIT_METADATA_FIELD]: metadata
3855
+ [AUDIT_SOURCE_FIELD]: source,
3856
+ [AUDIT_METADATA_FIELD]: metadata
2902
3857
  };
2903
3858
  });
2904
3859
  state.bgLogger().log([record]);
@@ -2917,7 +3872,7 @@ function updateSpanImpl({
2917
3872
  ...event
2918
3873
  })
2919
3874
  );
2920
- const parentIds = async () => new (0, _core.SpanComponentsV3)({
3875
+ const parentIds = async () => new SpanComponentsV3({
2921
3876
  object_type: parentObjectType,
2922
3877
  object_id: await parentObjectId.get()
2923
3878
  }).objectIdFields();
@@ -2925,7 +3880,7 @@ function updateSpanImpl({
2925
3880
  id,
2926
3881
  ...updateEvent,
2927
3882
  ...await parentIds(),
2928
- [_core.IS_MERGE_FIELD]: true
3883
+ [IS_MERGE_FIELD]: true
2929
3884
  }));
2930
3885
  state.bgLogger().log([record]);
2931
3886
  }
@@ -2935,7 +3890,7 @@ function updateSpan({
2935
3890
  ...event
2936
3891
  }) {
2937
3892
  const resolvedState = _nullishCoalesce(state, () => ( _globalState));
2938
- const components = _core.SpanComponentsV3.fromStr(exported);
3893
+ const components = SpanComponentsV3.fromStr(exported);
2939
3894
  if (!components.data.row_id) {
2940
3895
  throw new Error("Exported span must have a row id");
2941
3896
  }
@@ -2960,15 +3915,15 @@ function spanComponentsToObjectIdLambda(state, components) {
2960
3915
  );
2961
3916
  }
2962
3917
  switch (components.data.object_type) {
2963
- case _core.SpanObjectTypeV3.EXPERIMENT:
3918
+ case 1 /* EXPERIMENT */:
2964
3919
  throw new Error(
2965
3920
  "Impossible: computeObjectMetadataArgs not supported for experiments"
2966
3921
  );
2967
- case _core.SpanObjectTypeV3.PLAYGROUND_LOGS:
3922
+ case 3 /* PLAYGROUND_LOGS */:
2968
3923
  throw new Error(
2969
3924
  "Impossible: computeObjectMetadataArgs not supported for prompt sessions"
2970
3925
  );
2971
- case _core.SpanObjectTypeV3.PROJECT_LOGS:
3926
+ case 2 /* PROJECT_LOGS */:
2972
3927
  return async () => (await computeLoggerMetadata(state, {
2973
3928
  ...components.data.compute_object_metadata_args
2974
3929
  })).project.id;
@@ -2997,9 +3952,9 @@ async function permalink(slug, opts) {
2997
3952
  if (slug === "") {
2998
3953
  return NOOP_SPAN_PERMALINK;
2999
3954
  }
3000
- const state = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _12 => _12.state]), () => ( _globalState));
3955
+ const state = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _22 => _22.state]), () => ( _globalState));
3001
3956
  const getOrgName = async () => {
3002
- if (_optionalChain([opts, 'optionalAccess', _13 => _13.orgName])) {
3957
+ if (_optionalChain([opts, 'optionalAccess', _23 => _23.orgName])) {
3003
3958
  return opts.orgName;
3004
3959
  }
3005
3960
  await state.login({});
@@ -3009,7 +3964,7 @@ async function permalink(slug, opts) {
3009
3964
  return state.orgName;
3010
3965
  };
3011
3966
  const getAppUrl = async () => {
3012
- if (_optionalChain([opts, 'optionalAccess', _14 => _14.appUrl])) {
3967
+ if (_optionalChain([opts, 'optionalAccess', _24 => _24.appUrl])) {
3013
3968
  return opts.appUrl;
3014
3969
  }
3015
3970
  await state.login({});
@@ -3019,8 +3974,8 @@ async function permalink(slug, opts) {
3019
3974
  return state.appUrl;
3020
3975
  };
3021
3976
  try {
3022
- const components = _core.SpanComponentsV3.fromStr(slug);
3023
- const object_type = _core.spanObjectTypeV3ToString.call(void 0, components.data.object_type);
3977
+ const components = SpanComponentsV3.fromStr(slug);
3978
+ const object_type = spanObjectTypeV3ToString(components.data.object_type);
3024
3979
  const [orgName, appUrl, object_id] = await Promise.all([
3025
3980
  getOrgName(),
3026
3981
  getAppUrl(),
@@ -3047,7 +4002,7 @@ function startSpanParentArgs(args) {
3047
4002
  if (args.parentSpanIds) {
3048
4003
  throw new Error("Cannot specify both parent and parentSpanIds");
3049
4004
  }
3050
- const parentComponents = _core.SpanComponentsV3.fromStr(args.parent);
4005
+ const parentComponents = SpanComponentsV3.fromStr(args.parent);
3051
4006
  if (args.parentObjectType !== parentComponents.data.object_type) {
3052
4007
  throw new Error(
3053
4008
  `Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
@@ -3120,7 +4075,7 @@ var Logger = (_class6 = class {
3120
4075
  return (async () => (await this.project).id)();
3121
4076
  }
3122
4077
  parentObjectType() {
3123
- return _core.SpanObjectTypeV3.PROJECT_LOGS;
4078
+ return 2 /* PROJECT_LOGS */;
3124
4079
  }
3125
4080
  /**
3126
4081
  * Log a single event. The event will be batched and uploaded behind the scenes if `logOptions.asyncFlush` is true.
@@ -3139,7 +4094,7 @@ var Logger = (_class6 = class {
3139
4094
  * @returns The `id` of the logged event.
3140
4095
  */
3141
4096
  log(event, options) {
3142
- if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _15 => _15.allowConcurrentWithSpans])) {
4097
+ if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _25 => _25.allowConcurrentWithSpans])) {
3143
4098
  throw new Error(
3144
4099
  "Cannot run toplevel `log` method while using spans. To log to the span, call `logger.traced` and then log with `span.log`"
3145
4100
  );
@@ -3207,14 +4162,14 @@ var Logger = (_class6 = class {
3207
4162
  state: this.state,
3208
4163
  ...startSpanParentArgs({
3209
4164
  state: this.state,
3210
- parent: _optionalChain([args, 'optionalAccess', _16 => _16.parent]),
4165
+ parent: _optionalChain([args, 'optionalAccess', _26 => _26.parent]),
3211
4166
  parentObjectType: this.parentObjectType(),
3212
4167
  parentObjectId: this.lazyId,
3213
4168
  parentComputeObjectMetadataArgs: this.computeMetadataArgs,
3214
- parentSpanIds: _optionalChain([args, 'optionalAccess', _17 => _17.parentSpanIds]),
3215
- propagatedEvent: _optionalChain([args, 'optionalAccess', _18 => _18.propagatedEvent])
4169
+ parentSpanIds: _optionalChain([args, 'optionalAccess', _27 => _27.parentSpanIds]),
4170
+ propagatedEvent: _optionalChain([args, 'optionalAccess', _28 => _28.propagatedEvent])
3216
4171
  }),
3217
- defaultRootType: _core.SpanTypeAttribute.TASK
4172
+ defaultRootType: "task" /* TASK */
3218
4173
  });
3219
4174
  }
3220
4175
  /**
@@ -3256,7 +4211,7 @@ var Logger = (_class6 = class {
3256
4211
  * See {@link Span.startSpan} for more details.
3257
4212
  */
3258
4213
  async export() {
3259
- return new (0, _core.SpanComponentsV3)({
4214
+ return new SpanComponentsV3({
3260
4215
  object_type: this.parentObjectType(),
3261
4216
  ...this.computeMetadataArgs && !this.lazyId.hasSucceeded ? { compute_object_metadata_args: this.computeMetadataArgs } : { object_id: await this.lazyId.get() }
3262
4217
  }).toStr();
@@ -3281,7 +4236,7 @@ function castLogger(logger, asyncFlush) {
3281
4236
  return logger;
3282
4237
  }
3283
4238
  function constructLogs3Data(items) {
3284
- return `{"rows": ${_core.constructJsonArray.call(void 0, items)}, "api_version": 2}`;
4239
+ return `{"rows": ${constructJsonArray(items)}, "api_version": 2}`;
3285
4240
  }
3286
4241
  function now() {
3287
4242
  return (/* @__PURE__ */ new Date()).getTime();
@@ -3307,7 +4262,7 @@ var TestBackgroundLogger = (_class7 = class {constructor() { _class7.prototype._
3307
4262
  events.push(await event.get());
3308
4263
  }
3309
4264
  }
3310
- const batch = _core.mergeRowBatch.call(void 0, events);
4265
+ const batch = mergeRowBatch(events);
3311
4266
  let flatBatch = batch.flat();
3312
4267
  if (this.maskingFunction) {
3313
4268
  flatBatch = flatBatch.map((item) => {
@@ -3450,7 +4405,7 @@ var HTTPBackgroundLogger = (_class8 = class _HTTPBackgroundLogger {
3450
4405
  this.queue.clear();
3451
4406
  return;
3452
4407
  }
3453
- const batchSize = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _19 => _19.batchSize]), () => ( this.defaultBatchSize));
4408
+ const batchSize = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _29 => _29.batchSize]), () => ( this.defaultBatchSize));
3454
4409
  const wrappedItems = this.queue.drain();
3455
4410
  const [allItems, attachments] = await this.unwrapLazyValues(wrappedItems);
3456
4411
  if (allItems.length === 0) {
@@ -3459,7 +4414,7 @@ var HTTPBackgroundLogger = (_class8 = class _HTTPBackgroundLogger {
3459
4414
  const allItemsStr = allItems.map(
3460
4415
  (bucket) => bucket.map((item) => JSON.stringify(item))
3461
4416
  );
3462
- const batchSets = _core.batchItems.call(void 0, {
4417
+ const batchSets = batchItems({
3463
4418
  items: allItemsStr,
3464
4419
  batchMaxNumItems: batchSize,
3465
4420
  batchMaxNumBytes: this.maxRequestSize / 2
@@ -3513,7 +4468,7 @@ var HTTPBackgroundLogger = (_class8 = class _HTTPBackgroundLogger {
3513
4468
  const items = await Promise.all(wrappedItems.map((x) => x.get()));
3514
4469
  const attachments = [];
3515
4470
  items.forEach((item) => extractAttachments(item, attachments));
3516
- let mergedItems = _core.mergeRowBatch.call(void 0, items);
4471
+ let mergedItems = mergeRowBatch(items);
3517
4472
  if (this.maskingFunction) {
3518
4473
  mergedItems = mergedItems.map(
3519
4474
  (batch) => batch.map((item) => {
@@ -3699,10 +4654,10 @@ Error: ${errorText}`;
3699
4654
  } catch (err) {
3700
4655
  if (err instanceof AggregateError) {
3701
4656
  for (const e of err.errors) {
3702
- _optionalChain([this, 'access', _20 => _20.onFlushError, 'optionalCall', _21 => _21(e)]);
4657
+ _optionalChain([this, 'access', _30 => _30.onFlushError, 'optionalCall', _31 => _31(e)]);
3703
4658
  }
3704
4659
  } else {
3705
- _optionalChain([this, 'access', _22 => _22.onFlushError, 'optionalCall', _23 => _23(err)]);
4660
+ _optionalChain([this, 'access', _32 => _32.onFlushError, 'optionalCall', _33 => _33(err)]);
3706
4661
  }
3707
4662
  this.activeFlushError = err;
3708
4663
  } finally {
@@ -3832,7 +4787,7 @@ function init(projectOrOptions, optionalOptions) {
3832
4787
  }
3833
4788
  };
3834
4789
  if (gitMetadataSettings) {
3835
- mergedGitMetadataSettings = _core.mergeGitMetadataSettings.call(void 0,
4790
+ mergedGitMetadataSettings = mergeGitMetadataSettings(
3836
4791
  mergedGitMetadataSettings,
3837
4792
  gitMetadataSettings
3838
4793
  );
@@ -4257,7 +5212,7 @@ async function loginToState(options = {}) {
4257
5212
  return state;
4258
5213
  } else {
4259
5214
  const resp = await checkResponse(
4260
- await fetch2(_core._urljoin.call(void 0, state.appUrl, `/api/apikey/login`), {
5215
+ await fetch2(_urljoin(state.appUrl, `/api/apikey/login`), {
4261
5216
  method: "POST",
4262
5217
  headers: {
4263
5218
  "Content-Type": "application/json",
@@ -4315,23 +5270,25 @@ async function summarize(options = {}) {
4315
5270
  return await e.summarize(options);
4316
5271
  }
4317
5272
  function currentExperiment(options) {
4318
- const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _24 => _24.state]), () => ( _globalState));
5273
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _34 => _34.state]), () => ( _globalState));
4319
5274
  return state.currentExperiment;
4320
5275
  }
4321
5276
  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]));
5277
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _35 => _35.state]), () => ( _globalState));
5278
+ return castLogger(state.currentLogger, _optionalChain([options, 'optionalAccess', _36 => _36.asyncFlush]));
4324
5279
  }
4325
5280
  function currentSpan(options) {
4326
- const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _27 => _27.state]), () => ( _globalState));
5281
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _37 => _37.state]), () => ( _globalState));
4327
5282
  return _nullishCoalesce(state.currentSpan.getStore(), () => ( NOOP_SPAN));
4328
5283
  }
4329
5284
  function getSpanParentObject(options) {
4330
- const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _28 => _28.state]), () => ( _globalState));
5285
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _38 => _38.state]), () => ( _globalState));
4331
5286
  const parentSpan = currentSpan({ state });
4332
5287
  if (!Object.is(parentSpan, NOOP_SPAN)) {
4333
5288
  return parentSpan;
4334
5289
  }
5290
+ const parentStr = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _39 => _39.parent]), () => ( state.currentParent.getStore()));
5291
+ if (parentStr) return SpanComponentsV3.fromStr(parentStr);
4335
5292
  const experiment = currentExperiment();
4336
5293
  if (experiment) {
4337
5294
  return experiment;
@@ -4359,7 +5316,7 @@ function traced(callback, args) {
4359
5316
  const { span, isSyncFlushLogger } = startSpanAndIsLogger(args);
4360
5317
  const ret = runCatchFinally(
4361
5318
  () => {
4362
- if (_nullishCoalesce(_optionalChain([args, 'optionalAccess', _29 => _29.setCurrent]), () => ( true))) {
5319
+ if (_nullishCoalesce(_optionalChain([args, 'optionalAccess', _40 => _40.setCurrent]), () => ( true))) {
4363
5320
  return withCurrent(span, callback);
4364
5321
  } else {
4365
5322
  return callback(span);
@@ -4371,7 +5328,7 @@ function traced(callback, args) {
4371
5328
  },
4372
5329
  () => span.end()
4373
5330
  );
4374
- if (_optionalChain([args, 'optionalAccess', _30 => _30.asyncFlush]) === void 0 || _optionalChain([args, 'optionalAccess', _31 => _31.asyncFlush])) {
5331
+ if (_optionalChain([args, 'optionalAccess', _41 => _41.asyncFlush]) === void 0 || _optionalChain([args, 'optionalAccess', _42 => _42.asyncFlush])) {
4375
5332
  return ret;
4376
5333
  } else {
4377
5334
  return (async () => {
@@ -4495,14 +5452,14 @@ function wrapTraced(fn, args) {
4495
5452
  };
4496
5453
  const hasExplicitInput = args && args.event && "input" in args.event && args.event.input !== void 0;
4497
5454
  const hasExplicitOutput = args && args.event && args.event.output !== void 0;
4498
- const noTraceIO = _optionalChain([args, 'optionalAccess', _32 => _32.noTraceIO]) || hasExplicitInput || hasExplicitOutput;
5455
+ const noTraceIO = _optionalChain([args, 'optionalAccess', _43 => _43.noTraceIO]) || hasExplicitInput || hasExplicitOutput;
4499
5456
  if (isGeneratorFunction(fn)) {
4500
5457
  return wrapTracedSyncGenerator(fn, spanArgs, !!noTraceIO);
4501
5458
  }
4502
5459
  if (isAsyncGeneratorFunction(fn)) {
4503
5460
  return wrapTracedAsyncGenerator(fn, spanArgs, !!noTraceIO);
4504
5461
  }
4505
- if (_optionalChain([args, 'optionalAccess', _33 => _33.asyncFlush])) {
5462
+ if (_optionalChain([args, 'optionalAccess', _44 => _44.asyncFlush])) {
4506
5463
  return (...fnArgs) => traced((span) => {
4507
5464
  if (!hasExplicitInput) {
4508
5465
  span.log({ input: fnArgs });
@@ -4540,43 +5497,43 @@ function startSpan(args) {
4540
5497
  return startSpanAndIsLogger(args).span;
4541
5498
  }
4542
5499
  async function flush(options) {
4543
- const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _34 => _34.state]), () => ( _globalState));
5500
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _45 => _45.state]), () => ( _globalState));
4544
5501
  return await state.bgLogger().flush();
4545
5502
  }
4546
5503
  function setFetch(fetch2) {
4547
5504
  _globalState.setFetch(fetch2);
4548
5505
  }
4549
5506
  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
5507
+ const state = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _46 => _46.state]), () => ( _globalState));
5508
+ const parentObject = getSpanParentObject({
5509
+ asyncFlush: _optionalChain([args, 'optionalAccess', _47 => _47.asyncFlush]),
5510
+ parent: _optionalChain([args, 'optionalAccess', _48 => _48.parent]),
5511
+ state
5512
+ });
5513
+ if (parentObject instanceof SpanComponentsV3) {
5514
+ const parentSpanIds = parentObject.data.row_id ? {
5515
+ spanId: parentObject.data.span_id,
5516
+ rootSpanId: parentObject.data.root_span_id
4557
5517
  } : void 0;
4558
5518
  const span = new SpanImpl({
4559
5519
  state,
4560
5520
  ...args,
4561
- parentObjectType: components.data.object_type,
5521
+ parentObjectType: parentObject.data.object_type,
4562
5522
  parentObjectId: new LazyValue(
4563
- spanComponentsToObjectIdLambda(state, components)
5523
+ spanComponentsToObjectIdLambda(state, parentObject)
4564
5524
  ),
4565
- parentComputeObjectMetadataArgs: _nullishCoalesce(components.data.compute_object_metadata_args, () => ( void 0)),
5525
+ parentComputeObjectMetadataArgs: _nullishCoalesce(parentObject.data.compute_object_metadata_args, () => ( void 0)),
4566
5526
  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)))))
5527
+ propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _49 => _49.propagatedEvent]), () => ( // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
5528
+ (_nullishCoalesce(parentObject.data.propagated_event, () => ( void 0)))))
4569
5529
  });
4570
5530
  return {
4571
5531
  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
5532
+ isSyncFlushLogger: parentObject.data.object_type === 2 /* PROJECT_LOGS */ && // Since there's no parent logger here, we're free to choose the async flush
4573
5533
  // behavior, and therefore propagate along whatever we get from the arguments
4574
- _optionalChain([args, 'optionalAccess', _38 => _38.asyncFlush]) === false
5534
+ _optionalChain([args, 'optionalAccess', _50 => _50.asyncFlush]) === false
4575
5535
  };
4576
5536
  } else {
4577
- const parentObject = getSpanParentObject({
4578
- asyncFlush: _optionalChain([args, 'optionalAccess', _39 => _39.asyncFlush])
4579
- });
4580
5537
  const span = parentObject.startSpan(args);
4581
5538
  return {
4582
5539
  span,
@@ -4763,10 +5720,10 @@ function extractAttachments(event, attachments) {
4763
5720
  event[key] = value.reference;
4764
5721
  continue;
4765
5722
  }
4766
- if (_optionalChain([value, 'optionalAccess', _40 => _40.type]) === BRAINTRUST_ATTACHMENT && value.key && !value.uploader) {
5723
+ if (_optionalChain([value, 'optionalAccess', _51 => _51.type]) === BRAINTRUST_ATTACHMENT && value.key && !value.uploader) {
4767
5724
  continue;
4768
5725
  }
4769
- if (_optionalChain([value, 'optionalAccess', _41 => _41.reference, 'optionalAccess', _42 => _42.type]) === BRAINTRUST_ATTACHMENT && _optionalChain([value, 'optionalAccess', _43 => _43.uploader])) {
5726
+ if (_optionalChain([value, 'optionalAccess', _52 => _52.reference, 'optionalAccess', _53 => _53.type]) === BRAINTRUST_ATTACHMENT && _optionalChain([value, 'optionalAccess', _54 => _54.uploader])) {
4770
5727
  const attachment = new Attachment({
4771
5728
  data: value.dataDebugString,
4772
5729
  filename: value.reference.filename,
@@ -4904,7 +5861,7 @@ var ObjectFetcher = (_class9 = class {
4904
5861
  throw new Error("Too many BTQL iterations");
4905
5862
  }
4906
5863
  }
4907
- this._fetchedData = this.mutateRecord ? _optionalChain([data, 'optionalAccess', _44 => _44.map, 'call', _45 => _45(this.mutateRecord)]) : data;
5864
+ this._fetchedData = this.mutateRecord ? _optionalChain([data, 'optionalAccess', _55 => _55.map, 'call', _56 => _56(this.mutateRecord)]) : data;
4908
5865
  }
4909
5866
  return this._fetchedData || [];
4910
5867
  }
@@ -4918,7 +5875,7 @@ var ObjectFetcher = (_class9 = class {
4918
5875
  const fetchedData = await this.fetchedData();
4919
5876
  let maxVersion = void 0;
4920
5877
  for (const record of fetchedData) {
4921
- const xactId = String(_nullishCoalesce(record[_core.TRANSACTION_ID_FIELD], () => ( "0")));
5878
+ const xactId = String(_nullishCoalesce(record[TRANSACTION_ID_FIELD], () => ( "0")));
4922
5879
  if (maxVersion === void 0 || xactId > maxVersion) {
4923
5880
  maxVersion = xactId;
4924
5881
  }
@@ -4961,7 +5918,7 @@ var Experiment2 = (_class10 = class extends ObjectFetcher {
4961
5918
  })();
4962
5919
  }
4963
5920
  parentObjectType() {
4964
- return _core.SpanObjectTypeV3.EXPERIMENT;
5921
+ return 1 /* EXPERIMENT */;
4965
5922
  }
4966
5923
  async getState() {
4967
5924
  await this.lazyMetadata.get();
@@ -4985,7 +5942,7 @@ var Experiment2 = (_class10 = class extends ObjectFetcher {
4985
5942
  * @returns The `id` of the logged event.
4986
5943
  */
4987
5944
  log(event, options) {
4988
- if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _46 => _46.allowConcurrentWithSpans])) {
5945
+ if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _57 => _57.allowConcurrentWithSpans])) {
4989
5946
  throw new Error(
4990
5947
  "Cannot run toplevel `log` method while using spans. To log to the span, call `experiment.traced` and then log with `span.log`"
4991
5948
  );
@@ -5038,14 +5995,14 @@ var Experiment2 = (_class10 = class extends ObjectFetcher {
5038
5995
  state: this.state,
5039
5996
  ...startSpanParentArgs({
5040
5997
  state: this.state,
5041
- parent: _optionalChain([args, 'optionalAccess', _47 => _47.parent]),
5998
+ parent: _optionalChain([args, 'optionalAccess', _58 => _58.parent]),
5042
5999
  parentObjectType: this.parentObjectType(),
5043
6000
  parentObjectId: this.lazyId,
5044
6001
  parentComputeObjectMetadataArgs: void 0,
5045
6002
  parentSpanIds: void 0,
5046
- propagatedEvent: _optionalChain([args, 'optionalAccess', _48 => _48.propagatedEvent])
6003
+ propagatedEvent: _optionalChain([args, 'optionalAccess', _59 => _59.propagatedEvent])
5047
6004
  }),
5048
- defaultRootType: _core.SpanTypeAttribute.EVAL
6005
+ defaultRootType: "eval" /* EVAL */
5049
6006
  });
5050
6007
  }
5051
6008
  async fetchBaseExperiment() {
@@ -5169,7 +6126,7 @@ View complete results in Braintrust or run experiment.summarize() again.`
5169
6126
  * See {@link Span.startSpan} for more details.
5170
6127
  */
5171
6128
  async export() {
5172
- return new (0, _core.SpanComponentsV3)({
6129
+ return new SpanComponentsV3({
5173
6130
  object_type: this.parentObjectType(),
5174
6131
  object_id: await this.id
5175
6132
  }).toStr();
@@ -5256,7 +6213,7 @@ var SpanImpl = (_class11 = class _SpanImpl {
5256
6213
  this.parentComputeObjectMetadataArgs = args.parentComputeObjectMetadataArgs;
5257
6214
  this.propagatedEvent = args.propagatedEvent;
5258
6215
  if (this.propagatedEvent) {
5259
- _core.mergeDicts.call(void 0, rawEvent, this.propagatedEvent);
6216
+ mergeDicts(rawEvent, this.propagatedEvent);
5260
6217
  }
5261
6218
  const { id: eventId, ...event } = rawEvent;
5262
6219
  const callerLocation = isomorph_default.getCallerLocation();
@@ -5333,12 +6290,12 @@ var SpanImpl = (_class11 = class _SpanImpl {
5333
6290
  root_span_id: this._rootSpanId,
5334
6291
  span_parents: this._spanParents,
5335
6292
  ...serializableInternalData,
5336
- [_core.IS_MERGE_FIELD]: this.isMerge
6293
+ [IS_MERGE_FIELD]: this.isMerge
5337
6294
  });
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]);
6295
+ if (_optionalChain([partialRecord, 'access', _60 => _60.metrics, 'optionalAccess', _61 => _61.end])) {
6296
+ this.loggedEndTime = _optionalChain([partialRecord, 'access', _62 => _62.metrics, 'optionalAccess', _63 => _63.end]);
5340
6297
  }
5341
- if ((_nullishCoalesce(partialRecord.tags, () => ( []))).length > 0 && _optionalChain([this, 'access', _53 => _53._spanParents, 'optionalAccess', _54 => _54.length])) {
6298
+ if ((_nullishCoalesce(partialRecord.tags, () => ( []))).length > 0 && _optionalChain([this, 'access', _64 => _64._spanParents, 'optionalAccess', _65 => _65.length])) {
5342
6299
  throw new Error("Tags can only be logged to the root span");
5343
6300
  }
5344
6301
  const computeRecord = async () => ({
@@ -5351,7 +6308,7 @@ var SpanImpl = (_class11 = class _SpanImpl {
5351
6308
  ])
5352
6309
  )
5353
6310
  ),
5354
- ...new (0, _core.SpanComponentsV3)({
6311
+ ...new SpanComponentsV3({
5355
6312
  object_type: this.parentObjectType,
5356
6313
  object_id: await this.parentObjectId.get()
5357
6314
  }).objectIdFields()
@@ -5383,18 +6340,18 @@ var SpanImpl = (_class11 = class _SpanImpl {
5383
6340
  );
5384
6341
  }
5385
6342
  startSpan(args) {
5386
- const parentSpanIds = _optionalChain([args, 'optionalAccess', _55 => _55.parent]) ? void 0 : { spanId: this._spanId, rootSpanId: this._rootSpanId };
6343
+ const parentSpanIds = _optionalChain([args, 'optionalAccess', _66 => _66.parent]) ? void 0 : { spanId: this._spanId, rootSpanId: this._rootSpanId };
5387
6344
  return new _SpanImpl({
5388
6345
  state: this._state,
5389
6346
  ...args,
5390
6347
  ...startSpanParentArgs({
5391
6348
  state: this._state,
5392
- parent: _optionalChain([args, 'optionalAccess', _56 => _56.parent]),
6349
+ parent: _optionalChain([args, 'optionalAccess', _67 => _67.parent]),
5393
6350
  parentObjectType: this.parentObjectType,
5394
6351
  parentObjectId: this.parentObjectId,
5395
6352
  parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
5396
6353
  parentSpanIds,
5397
- propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _57 => _57.propagatedEvent]), () => ( this.propagatedEvent))
6354
+ propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _68 => _68.propagatedEvent]), () => ( this.propagatedEvent))
5398
6355
  })
5399
6356
  });
5400
6357
  }
@@ -5408,12 +6365,12 @@ var SpanImpl = (_class11 = class _SpanImpl {
5408
6365
  ...args,
5409
6366
  ...startSpanParentArgs({
5410
6367
  state: this._state,
5411
- parent: _optionalChain([args, 'optionalAccess', _58 => _58.parent]),
6368
+ parent: _optionalChain([args, 'optionalAccess', _69 => _69.parent]),
5412
6369
  parentObjectType: this.parentObjectType,
5413
6370
  parentObjectId: this.parentObjectId,
5414
6371
  parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
5415
6372
  parentSpanIds,
5416
- propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _59 => _59.propagatedEvent]), () => ( this.propagatedEvent))
6373
+ propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _70 => _70.propagatedEvent]), () => ( this.propagatedEvent))
5417
6374
  }),
5418
6375
  spanId
5419
6376
  });
@@ -5422,7 +6379,7 @@ var SpanImpl = (_class11 = class _SpanImpl {
5422
6379
  let endTime;
5423
6380
  let internalData = {};
5424
6381
  if (!this.loggedEndTime) {
5425
- endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _60 => _60.endTime]), () => ( getCurrentUnixTimestamp()));
6382
+ endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _71 => _71.endTime]), () => ( getCurrentUnixTimestamp()));
5426
6383
  internalData = { metrics: { end: endTime } };
5427
6384
  } else {
5428
6385
  endTime = this.loggedEndTime;
@@ -5431,7 +6388,7 @@ var SpanImpl = (_class11 = class _SpanImpl {
5431
6388
  return endTime;
5432
6389
  }
5433
6390
  async export() {
5434
- return new (0, _core.SpanComponentsV3)({
6391
+ return new SpanComponentsV3({
5435
6392
  object_type: this.parentObjectType,
5436
6393
  ...this.parentComputeObjectMetadataArgs && !this.parentObjectId.hasSucceeded ? { compute_object_metadata_args: this.parentComputeObjectMetadataArgs } : { object_id: await this.parentObjectId.get() },
5437
6394
  row_id: this.id,
@@ -5464,9 +6421,9 @@ var SpanImpl = (_class11 = class _SpanImpl {
5464
6421
  const baseUrl = `${appUrl}/app/${orgName}`;
5465
6422
  const args = this.parentComputeObjectMetadataArgs;
5466
6423
  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]);
6424
+ case 2 /* PROJECT_LOGS */: {
6425
+ const projectID = _optionalChain([args, 'optionalAccess', _72 => _72.project_id]) || this.parentObjectId.getSync().value;
6426
+ const projectName = _optionalChain([args, 'optionalAccess', _73 => _73.project_name]);
5470
6427
  if (projectID) {
5471
6428
  return `${baseUrl}/object?object_type=project_logs&object_id=${projectID}&id=${this._id}`;
5472
6429
  } else if (projectName) {
@@ -5475,15 +6432,15 @@ var SpanImpl = (_class11 = class _SpanImpl {
5475
6432
  return getErrPermlink("provide-project-name-or-id");
5476
6433
  }
5477
6434
  }
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]);
6435
+ case 1 /* EXPERIMENT */: {
6436
+ 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
6437
  if (!expID) {
5481
6438
  return getErrPermlink("provide-experiment-id");
5482
6439
  } else {
5483
6440
  return `${baseUrl}/object?object_type=experiment&object_id=${expID}&id=${this._id}`;
5484
6441
  }
5485
6442
  }
5486
- case _core.SpanObjectTypeV3.PLAYGROUND_LOGS: {
6443
+ case 3 /* PLAYGROUND_LOGS */: {
5487
6444
  return NOOP_SPAN_PERMALINK;
5488
6445
  }
5489
6446
  default: {
@@ -5509,8 +6466,8 @@ function splitLoggingData({
5509
6466
  }) {
5510
6467
  const sanitized = validateAndSanitizeExperimentLogPartialArgs(_nullishCoalesce(event, () => ( {})));
5511
6468
  const sanitizedAndInternalData = {};
5512
- _core.mergeDicts.call(void 0, sanitizedAndInternalData, internalData || {});
5513
- _core.mergeDicts.call(void 0, sanitizedAndInternalData, sanitized);
6469
+ mergeDicts(sanitizedAndInternalData, internalData || {});
6470
+ mergeDicts(sanitizedAndInternalData, sanitized);
5514
6471
  const serializableInternalData = {};
5515
6472
  const lazyInternalData = {};
5516
6473
  for (const [key, value] of Object.entries(sanitizedAndInternalData)) {
@@ -5535,7 +6492,7 @@ function splitLoggingData({
5535
6492
  }
5536
6493
  var Dataset2 = (_class12 = class extends ObjectFetcher {
5537
6494
  constructor(state, lazyMetadata, pinnedVersion, legacy, _internal_btql) {
5538
- const isLegacyDataset = _nullishCoalesce(legacy, () => ( _core.DEFAULT_IS_LEGACY_DATASET));
6495
+ const isLegacyDataset = _nullishCoalesce(legacy, () => ( DEFAULT_IS_LEGACY_DATASET));
5539
6496
  if (isLegacyDataset) {
5540
6497
  console.warn(
5541
6498
  `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 +6503,7 @@ var Dataset2 = (_class12 = class extends ObjectFetcher {
5546
6503
  pinnedVersion,
5547
6504
  (r) => (
5548
6505
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
5549
- _core.ensureDatasetRecord.call(void 0,
6506
+ ensureDatasetRecord(
5550
6507
  enrichAttachments(r, this.state),
5551
6508
  isLegacyDataset
5552
6509
  )
@@ -5622,7 +6579,7 @@ var Dataset2 = (_class12 = class extends ObjectFetcher {
5622
6579
  //if we're merging/updating an event we will not add this ts
5623
6580
  metadata,
5624
6581
  ...!!isMerge ? {
5625
- [_core.IS_MERGE_FIELD]: true
6582
+ [IS_MERGE_FIELD]: true
5626
6583
  } : {}
5627
6584
  };
5628
6585
  return args;
@@ -5783,7 +6740,7 @@ function renderMessage(render, message) {
5783
6740
  case "text":
5784
6741
  return { ...c, text: render(c.text) };
5785
6742
  case "image_url":
5786
- if (_core.isObject.call(void 0, c.image_url.url)) {
6743
+ if (isObject(c.image_url.url)) {
5787
6744
  throw new Error(
5788
6745
  "Attachments must be replaced with URLs before calling `build()`"
5789
6746
  );
@@ -5842,9 +6799,9 @@ function renderTemplatedObject(obj, args, options) {
5842
6799
  }
5843
6800
  }
5844
6801
  });
5845
- } else if (_core.isArray.call(void 0, obj)) {
6802
+ } else if (isArray(obj)) {
5846
6803
  return obj.map((item) => renderTemplatedObject(item, args, options));
5847
- } else if (_core.isObject.call(void 0, obj)) {
6804
+ } else if (isObject(obj)) {
5848
6805
  return Object.fromEntries(
5849
6806
  Object.entries(obj).map(([key, value]) => [
5850
6807
  key,
@@ -5902,13 +6859,13 @@ var Prompt2 = (_class13 = class _Prompt {
5902
6859
  return "slug" in this.metadata ? this.metadata.slug : this.metadata.id;
5903
6860
  }
5904
6861
  get prompt() {
5905
- return _optionalChain([this, 'access', _68 => _68.getParsedPromptData, 'call', _69 => _69(), 'optionalAccess', _70 => _70.prompt]);
6862
+ return _optionalChain([this, 'access', _79 => _79.getParsedPromptData, 'call', _80 => _80(), 'optionalAccess', _81 => _81.prompt]);
5906
6863
  }
5907
6864
  get version() {
5908
- return this.metadata[_core.TRANSACTION_ID_FIELD];
6865
+ return this.metadata[TRANSACTION_ID_FIELD];
5909
6866
  }
5910
6867
  get options() {
5911
- return _optionalChain([this, 'access', _71 => _71.getParsedPromptData, 'call', _72 => _72(), 'optionalAccess', _73 => _73.options]) || {};
6868
+ return _optionalChain([this, 'access', _82 => _82.getParsedPromptData, 'call', _83 => _83(), 'optionalAccess', _84 => _84.options]) || {};
5912
6869
  }
5913
6870
  get promptData() {
5914
6871
  return this.getParsedPromptData();
@@ -6059,7 +7016,7 @@ var Prompt2 = (_class13 = class _Prompt {
6059
7016
  return {
6060
7017
  type: "chat",
6061
7018
  messages,
6062
- ..._optionalChain([prompt, 'access', _74 => _74.tools, 'optionalAccess', _75 => _75.trim, 'call', _76 => _76()]) ? {
7019
+ ..._optionalChain([prompt, 'access', _85 => _85.tools, 'optionalAccess', _86 => _86.trim, 'call', _87 => _87()]) ? {
6063
7020
  tools: render(prompt.tools)
6064
7021
  } : void 0
6065
7022
  };
@@ -6169,9 +7126,9 @@ async function getPromptVersions(projectId, promptId) {
6169
7126
  );
6170
7127
  }
6171
7128
  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))]) || [];
7129
+ return _optionalChain([result, 'access', _88 => _88.data, 'optionalAccess', _89 => _89.filter, 'call', _90 => _90(
7130
+ (entry) => ["upsert", "merge"].includes(_optionalChain([entry, 'access', _91 => _91.audit_data, 'optionalAccess', _92 => _92.action]))
7131
+ ), 'access', _93 => _93.map, 'call', _94 => _94((entry) => prettifyXact(entry._xact_id))]) || [];
6175
7132
  }
6176
7133
  var _exportsForTestingOnly = {
6177
7134
  extractAttachments,
@@ -6196,7 +7153,7 @@ function configureBrowser() {
6196
7153
  if (typeof AsyncLocalStorage !== "undefined") {
6197
7154
  isomorph_default.newAsyncLocalStorage = () => new AsyncLocalStorage();
6198
7155
  }
6199
- } catch (e3) {
7156
+ } catch (e5) {
6200
7157
  }
6201
7158
  isomorph_default.getEnv = (name) => {
6202
7159
  if (typeof process === "undefined" || typeof process.env === "undefined") {
@@ -6380,12 +7337,7 @@ function initFunction({
6380
7337
  return f;
6381
7338
  }
6382
7339
 
6383
- // src/wrappers/oai.ts
6384
-
6385
-
6386
-
6387
7340
  // src/wrappers/oai_responses.ts
6388
-
6389
7341
  function responsesProxy(openai) {
6390
7342
  if (!openai.responses) {
6391
7343
  return openai;
@@ -6413,19 +7365,15 @@ function responsesCreateProxy(target) {
6413
7365
  return proxyCreate(target, hooks);
6414
7366
  }
6415
7367
  function parseSpanFromResponseCreateParams(params) {
6416
- const input = [{ role: "user", content: params.input }];
6417
- if (params.instructions) {
6418
- input.push({ role: "system", content: params.instructions });
6419
- }
6420
7368
  const spanArgs = {
6421
7369
  name: "openai.responses.create",
6422
7370
  spanAttributes: {
6423
7371
  type: "llm"
6424
7372
  },
6425
7373
  event: {
6426
- input,
7374
+ input: params.input,
6427
7375
  metadata: {
6428
- ...filterFrom(params, ["input", "instructions"]),
7376
+ ...filterFrom(params, ["input"]),
6429
7377
  provider: "openai"
6430
7378
  }
6431
7379
  },
@@ -6437,25 +7385,29 @@ function parseSpanFromResponseCreateParams(params) {
6437
7385
  };
6438
7386
  }
6439
7387
  function parseEventFromResponseCreateResult(result) {
6440
- return {
6441
- output: _optionalChain([result, 'optionalAccess', _84 => _84.output_text]) || "",
6442
- metrics: parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _85 => _85.usage]))
6443
- };
7388
+ const data = {};
7389
+ if (_optionalChain([result, 'optionalAccess', _95 => _95.output]) !== void 0) {
7390
+ data.output = result.output;
7391
+ }
7392
+ if (result) {
7393
+ const { output, usage, ...metadata } = result;
7394
+ if (Object.keys(metadata).length > 0) {
7395
+ data.metadata = metadata;
7396
+ }
7397
+ }
7398
+ data.metrics = parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _96 => _96.usage]));
7399
+ return data;
6444
7400
  }
6445
7401
  function parseSpanFromResponseParseParams(params) {
6446
- const input = [{ role: "user", content: params.input }];
6447
- if (params.instructions) {
6448
- input.push({ role: "system", content: params.instructions });
6449
- }
6450
7402
  const spanArgs = {
6451
7403
  name: "openai.responses.parse",
6452
7404
  spanAttributes: {
6453
7405
  type: "llm"
6454
7406
  },
6455
7407
  event: {
6456
- input,
7408
+ input: params.input,
6457
7409
  metadata: {
6458
- ...filterFrom(params, ["input", "instructions"]),
7410
+ ...filterFrom(params, ["input"]),
6459
7411
  provider: "openai"
6460
7412
  }
6461
7413
  },
@@ -6467,10 +7419,18 @@ function parseSpanFromResponseParseParams(params) {
6467
7419
  };
6468
7420
  }
6469
7421
  function parseEventFromResponseParseResult(result) {
6470
- return {
6471
- output: _optionalChain([result, 'optionalAccess', _86 => _86.output_parsed]) || _optionalChain([result, 'optionalAccess', _87 => _87.output_text]) || "",
6472
- metrics: parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _88 => _88.usage]))
6473
- };
7422
+ const data = {};
7423
+ if (_optionalChain([result, 'optionalAccess', _97 => _97.output]) !== void 0) {
7424
+ data.output = result.output;
7425
+ }
7426
+ if (result) {
7427
+ const { output, usage, ...metadata } = result;
7428
+ if (Object.keys(metadata).length > 0) {
7429
+ data.metadata = metadata;
7430
+ }
7431
+ }
7432
+ data.metrics = parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _98 => _98.usage]));
7433
+ return data;
6474
7434
  }
6475
7435
  function traceResponseCreateStream(stream, timedSpan) {
6476
7436
  const span = timedSpan.span;
@@ -6486,7 +7446,7 @@ function traceResponseCreateStream(stream, timedSpan) {
6486
7446
  return result;
6487
7447
  }
6488
7448
  const item = result.value;
6489
- if (!item || !_optionalChain([item, 'optionalAccess', _89 => _89.type]) || !_optionalChain([item, 'optionalAccess', _90 => _90.response])) {
7449
+ if (!item || !_optionalChain([item, 'optionalAccess', _99 => _99.type]) || !_optionalChain([item, 'optionalAccess', _100 => _100.response])) {
6490
7450
  return result;
6491
7451
  }
6492
7452
  const event = parseLogFromItem(item);
@@ -6497,24 +7457,24 @@ function traceResponseCreateStream(stream, timedSpan) {
6497
7457
  };
6498
7458
  }
6499
7459
  function parseLogFromItem(item) {
6500
- if (!item || !_optionalChain([item, 'optionalAccess', _91 => _91.type]) || !_optionalChain([item, 'optionalAccess', _92 => _92.response])) {
7460
+ if (!item || !_optionalChain([item, 'optionalAccess', _101 => _101.type]) || !_optionalChain([item, 'optionalAccess', _102 => _102.response])) {
6501
7461
  return {};
6502
7462
  }
6503
7463
  const response = item.response;
6504
7464
  switch (item.type) {
6505
7465
  case "response.completed":
6506
- const texts = [];
6507
- for (const output of _optionalChain([response, 'optionalAccess', _93 => _93.output]) || []) {
6508
- for (const content of _optionalChain([output, 'optionalAccess', _94 => _94.content]) || []) {
6509
- if (_optionalChain([content, 'optionalAccess', _95 => _95.type]) === "output_text") {
6510
- texts.push(content.text);
6511
- }
7466
+ const data = {};
7467
+ if (_optionalChain([response, 'optionalAccess', _103 => _103.output]) !== void 0) {
7468
+ data.output = response.output;
7469
+ }
7470
+ if (response) {
7471
+ const { usage, output, ...metadata } = response;
7472
+ if (Object.keys(metadata).length > 0) {
7473
+ data.metadata = metadata;
6512
7474
  }
6513
7475
  }
6514
- return {
6515
- output: texts.join(""),
6516
- metrics: parseMetricsFromUsage(_optionalChain([response, 'optionalAccess', _96 => _96.usage]))
6517
- };
7476
+ data.metrics = parseMetricsFromUsage(_optionalChain([response, 'optionalAccess', _104 => _104.usage]));
7477
+ return data;
6518
7478
  default:
6519
7479
  return {};
6520
7480
  }
@@ -6575,7 +7535,7 @@ function parseMetricsFromUsage(usage) {
6575
7535
  const metricName = TOKEN_NAME_MAP[oai_name] || oai_name;
6576
7536
  metrics[metricName] = value;
6577
7537
  } else if (oai_name.endsWith("_tokens_details")) {
6578
- if (!_core.isObject.call(void 0, value)) {
7538
+ if (!isObject(value)) {
6579
7539
  continue;
6580
7540
  }
6581
7541
  const rawPrefix = oai_name.slice(0, -"_tokens_details".length);
@@ -6697,8 +7657,8 @@ function wrapOpenAIv4(openai) {
6697
7657
  const embeddingProxy = createEndpointProxy(openai.embeddings, wrapEmbeddings);
6698
7658
  const moderationProxy = createEndpointProxy(openai.moderations, wrapModerations);
6699
7659
  let betaProxy;
6700
- if (_optionalChain([openai, 'access', _97 => _97.beta, 'optionalAccess', _98 => _98.chat, 'optionalAccess', _99 => _99.completions, 'optionalAccess', _100 => _100.stream])) {
6701
- const betaChatCompletionProxy = new Proxy(_optionalChain([openai, 'optionalAccess', _101 => _101.beta, 'optionalAccess', _102 => _102.chat, 'access', _103 => _103.completions]), {
7660
+ if (_optionalChain([openai, 'access', _105 => _105.beta, 'optionalAccess', _106 => _106.chat, 'optionalAccess', _107 => _107.completions, 'optionalAccess', _108 => _108.stream])) {
7661
+ const betaChatCompletionProxy = new Proxy(_optionalChain([openai, 'optionalAccess', _109 => _109.beta, 'optionalAccess', _110 => _110.chat, 'access', _111 => _111.completions]), {
6702
7662
  get(target, name, receiver) {
6703
7663
  const baseVal = Reflect.get(target, name, receiver);
6704
7664
  if (name === "parse") {
@@ -6746,7 +7706,7 @@ function wrapOpenAIv4(openai) {
6746
7706
  });
6747
7707
  }
6748
7708
  function logCompletionResponse(startTime, response, span) {
6749
- const metrics = parseMetricsFromUsage(_optionalChain([response, 'optionalAccess', _104 => _104.usage]));
7709
+ const metrics = parseMetricsFromUsage(_optionalChain([response, 'optionalAccess', _112 => _112.usage]));
6750
7710
  metrics.time_to_first_token = getCurrentUnixTimestamp() - startTime;
6751
7711
  span.log({
6752
7712
  output: response.choices,
@@ -6757,11 +7717,11 @@ function wrapBetaChatCompletionParse(completion) {
6757
7717
  return async (allParams) => {
6758
7718
  const { span_info: _, ...params } = allParams;
6759
7719
  const span = startSpan(
6760
- _core.mergeDicts.call(void 0,
7720
+ mergeDicts(
6761
7721
  {
6762
7722
  name: "Chat Completion",
6763
7723
  spanAttributes: {
6764
- type: _core.SpanTypeAttribute.LLM
7724
+ type: "llm" /* LLM */
6765
7725
  }
6766
7726
  },
6767
7727
  parseChatCompletionParams(allParams)
@@ -6781,11 +7741,11 @@ function wrapBetaChatCompletionStream(completion) {
6781
7741
  return (allParams) => {
6782
7742
  const { span_info: _, ...params } = allParams;
6783
7743
  const span = startSpan(
6784
- _core.mergeDicts.call(void 0,
7744
+ mergeDicts(
6785
7745
  {
6786
7746
  name: "Chat Completion",
6787
7747
  spanAttributes: {
6788
- type: _core.SpanTypeAttribute.LLM
7748
+ type: "llm" /* LLM */
6789
7749
  }
6790
7750
  },
6791
7751
  parseChatCompletionParams(allParams)
@@ -6841,55 +7801,83 @@ function logHeaders(response, span) {
6841
7801
  }
6842
7802
  }
6843
7803
  function wrapChatCompletion(completion) {
6844
- return async (allParams, options) => {
7804
+ return (allParams, options) => {
6845
7805
  const { span_info: _, ...params } = allParams;
6846
- const span = startSpan(
6847
- _core.mergeDicts.call(void 0,
6848
- {
6849
- name: "Chat Completion",
6850
- spanAttributes: {
6851
- type: _core.SpanTypeAttribute.LLM
7806
+ let executionPromise = null;
7807
+ let dataPromise = null;
7808
+ const ensureExecuted = () => {
7809
+ if (!executionPromise) {
7810
+ executionPromise = (async () => {
7811
+ const span = startSpan(
7812
+ mergeDicts(
7813
+ {
7814
+ name: "Chat Completion",
7815
+ spanAttributes: {
7816
+ type: "llm" /* LLM */
7817
+ }
7818
+ },
7819
+ parseChatCompletionParams(allParams)
7820
+ )
7821
+ );
7822
+ const startTime = getCurrentUnixTimestamp();
7823
+ if (params.stream) {
7824
+ const { data: ret, response } = await completion(
7825
+ // We could get rid of this type coercion if we could somehow enforce
7826
+ // that `P extends ChatParams` BUT does not have the property
7827
+ // `span_info`.
7828
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
7829
+ params,
7830
+ options
7831
+ ).withResponse();
7832
+ logHeaders(response, span);
7833
+ const wrapperStream = new WrapperStream(
7834
+ span,
7835
+ startTime,
7836
+ ret.iterator()
7837
+ );
7838
+ ret.iterator = () => wrapperStream[Symbol.asyncIterator]();
7839
+ return { data: ret, response };
7840
+ } else {
7841
+ try {
7842
+ const completionResponse = completion(
7843
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
7844
+ params,
7845
+ options
7846
+ );
7847
+ const { data: ret, response } = await completionResponse.withResponse();
7848
+ logHeaders(response, span);
7849
+ const { messages, ...rest } = params;
7850
+ span.log({
7851
+ input: messages,
7852
+ metadata: {
7853
+ ...rest
7854
+ }
7855
+ });
7856
+ logCompletionResponse(startTime, ret, span);
7857
+ return { data: ret, response };
7858
+ } finally {
7859
+ span.end();
7860
+ }
6852
7861
  }
6853
- },
6854
- parseChatCompletionParams(allParams)
6855
- )
6856
- );
6857
- const startTime = getCurrentUnixTimestamp();
6858
- if (params.stream) {
6859
- const { data: ret, response } = await completion(
6860
- // We could get rid of this type coercion if we could somehow enforce
6861
- // that `P extends ChatParams` BUT does not have the property
6862
- // `span_info`.
6863
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
6864
- params,
6865
- options
6866
- ).withResponse();
6867
- logHeaders(response, span);
6868
- const wrapperStream = new WrapperStream(span, startTime, ret.iterator());
6869
- ret.iterator = () => wrapperStream[Symbol.asyncIterator]();
6870
- return ret;
6871
- } else {
6872
- try {
6873
- const completionResponse = completion(
6874
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
6875
- params,
6876
- options
6877
- );
6878
- const { data: ret, response } = await completionResponse.withResponse();
6879
- logHeaders(response, span);
6880
- const { messages, ...rest } = params;
6881
- span.log({
6882
- input: messages,
6883
- metadata: {
6884
- ...rest
7862
+ })();
7863
+ }
7864
+ return executionPromise;
7865
+ };
7866
+ return new Proxy({}, {
7867
+ get(target, prop, receiver) {
7868
+ if (prop === "withResponse") {
7869
+ return () => ensureExecuted();
7870
+ }
7871
+ if (prop === "then" || prop === "catch" || prop === "finally" || prop in Promise.prototype) {
7872
+ if (!dataPromise) {
7873
+ dataPromise = ensureExecuted().then((result) => result.data);
6885
7874
  }
6886
- });
6887
- logCompletionResponse(startTime, ret, span);
6888
- return ret;
6889
- } finally {
6890
- span.end();
7875
+ const value = Reflect.get(dataPromise, prop, receiver);
7876
+ return typeof value === "function" ? value.bind(dataPromise) : value;
7877
+ }
7878
+ return Reflect.get(target, prop, receiver);
6891
7879
  }
6892
- }
7880
+ });
6893
7881
  };
6894
7882
  }
6895
7883
  function parseBaseParams(allParams, inputField) {
@@ -6904,7 +7892,7 @@ function parseBaseParams(allParams, inputField) {
6904
7892
  const input = params[inputField];
6905
7893
  const paramsRest = { ...params, provider: "openai" };
6906
7894
  delete paramsRest[inputField];
6907
- return _core.mergeDicts.call(void 0, ret, { event: { input, metadata: paramsRest } });
7895
+ return mergeDicts(ret, { event: { input, metadata: paramsRest } });
6908
7896
  }
6909
7897
  function createApiWrapper(name, create, processResponse, parseParams) {
6910
7898
  return async (allParams, options) => {
@@ -6919,11 +7907,11 @@ function createApiWrapper(name, create, processResponse, parseParams) {
6919
7907
  processResponse(result, span);
6920
7908
  return result;
6921
7909
  },
6922
- _core.mergeDicts.call(void 0,
7910
+ mergeDicts(
6923
7911
  {
6924
7912
  name,
6925
7913
  spanAttributes: {
6926
- type: _core.SpanTypeAttribute.LLM
7914
+ type: "llm" /* LLM */
6927
7915
  }
6928
7916
  },
6929
7917
  parseParams(allParams)
@@ -6948,7 +7936,7 @@ function parseChatCompletionParams(params) {
6948
7936
  function processEmbeddingResponse(result, span) {
6949
7937
  span.log({
6950
7938
  output: { embedding_length: result.data[0].embedding.length },
6951
- metrics: parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _105 => _105.usage]))
7939
+ metrics: parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _113 => _113.usage]))
6952
7940
  });
6953
7941
  }
6954
7942
  function processModerationResponse(result, span) {
@@ -6978,10 +7966,10 @@ function postprocessStreamingResults(allResults) {
6978
7966
  if (result.usage) {
6979
7967
  metrics = {
6980
7968
  ...metrics,
6981
- ...parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _106 => _106.usage]))
7969
+ ...parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _114 => _114.usage]))
6982
7970
  };
6983
7971
  }
6984
- const delta = _optionalChain([result, 'access', _107 => _107.choices, 'optionalAccess', _108 => _108[0], 'optionalAccess', _109 => _109.delta]);
7972
+ const delta = _optionalChain([result, 'access', _115 => _115.choices, 'optionalAccess', _116 => _116[0], 'optionalAccess', _117 => _117.delta]);
6985
7973
  if (!delta) {
6986
7974
  continue;
6987
7975
  }
@@ -7063,43 +8051,43 @@ var WrapperStream = class {
7063
8051
 
7064
8052
  // dev/types.ts
7065
8053
 
7066
- var evalBodySchema = _zod.z.object({
7067
- name: _zod.z.string(),
7068
- parameters: _zod.z.record(_zod.z.string(), _zod.z.unknown()).nullish(),
8054
+ var evalBodySchema = _v3.z.object({
8055
+ name: _v3.z.string(),
8056
+ parameters: _v3.z.record(_v3.z.string(), _v3.z.unknown()).nullish(),
7069
8057
  data: RunEval.shape.data,
7070
- scores: _zod.z.array(
7071
- _zod.z.object({
8058
+ scores: _v3.z.array(
8059
+ _v3.z.object({
7072
8060
  function_id: FunctionId,
7073
- name: _zod.z.string()
8061
+ name: _v3.z.string()
7074
8062
  })
7075
8063
  ).nullish(),
7076
- experiment_name: _zod.z.string().nullish(),
7077
- project_id: _zod.z.string().nullish(),
8064
+ experiment_name: _v3.z.string().nullish(),
8065
+ project_id: _v3.z.string().nullish(),
7078
8066
  parent: InvokeParent.optional(),
7079
- stream: _zod.z.boolean().optional()
8067
+ stream: _v3.z.boolean().optional()
7080
8068
  });
7081
- var evalParametersSerializedSchema = _zod.z.record(
7082
- _zod.z.string(),
7083
- _zod.z.union([
7084
- _zod.z.object({
7085
- type: _zod.z.literal("prompt"),
8069
+ var evalParametersSerializedSchema = _v3.z.record(
8070
+ _v3.z.string(),
8071
+ _v3.z.union([
8072
+ _v3.z.object({
8073
+ type: _v3.z.literal("prompt"),
7086
8074
  default: PromptData.optional(),
7087
- description: _zod.z.string().optional()
8075
+ description: _v3.z.string().optional()
7088
8076
  }),
7089
- _zod.z.object({
7090
- type: _zod.z.literal("data"),
7091
- schema: _zod.z.record(_zod.z.unknown()),
8077
+ _v3.z.object({
8078
+ type: _v3.z.literal("data"),
8079
+ schema: _v3.z.record(_v3.z.unknown()),
7092
8080
  // JSON Schema
7093
- default: _zod.z.unknown().optional(),
7094
- description: _zod.z.string().optional()
8081
+ default: _v3.z.unknown().optional(),
8082
+ description: _v3.z.string().optional()
7095
8083
  })
7096
8084
  ])
7097
8085
  );
7098
- var evaluatorDefinitionSchema = _zod.z.object({
8086
+ var evaluatorDefinitionSchema = _v3.z.object({
7099
8087
  parameters: evalParametersSerializedSchema.optional()
7100
8088
  });
7101
- var evaluatorDefinitionsSchema = _zod.z.record(
7102
- _zod.z.string(),
8089
+ var evaluatorDefinitionsSchema = _v3.z.record(
8090
+ _v3.z.string(),
7103
8091
  evaluatorDefinitionSchema
7104
8092
  );
7105
8093