braintrust 0.0.199 → 0.0.201

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
@@ -60,6 +60,8 @@ __export(browser_exports, {
60
60
  default: () => browser_default,
61
61
  deserializePlainStringAsJSON: () => deserializePlainStringAsJSON,
62
62
  devNullWritableStream: () => devNullWritableStream,
63
+ evaluatorDefinitionSchema: () => evaluatorDefinitionSchema,
64
+ evaluatorDefinitionsSchema: () => evaluatorDefinitionsSchema,
63
65
  flush: () => flush,
64
66
  getSpanParentObject: () => getSpanParentObject,
65
67
  init: () => init,
@@ -396,11 +398,11 @@ function createFinalValuePassThroughStream(onFinal, onError) {
396
398
  break;
397
399
  default:
398
400
  const _type = chunkType;
399
- throw new Error(`Unknown chunk type ${_type}`);
401
+ onError(`Unknown chunk type: ${_type}`);
400
402
  }
401
403
  controller.enqueue(chunk);
402
404
  } else {
403
- throw new Error(`Unknown chunk type ${chunk}`);
405
+ onError(`Unknown chunk type ${JSON.stringify(chunk)}`);
404
406
  }
405
407
  },
406
408
  flush(controller) {
@@ -431,11 +433,12 @@ function devNullWritableStream() {
431
433
 
432
434
  // src/prompt-cache/disk-cache.ts
433
435
  function canUseDiskCache() {
434
- return !!(isomorph_default.gunzip && isomorph_default.gzip && isomorph_default.stat && isomorph_default.readFile && isomorph_default.writeFile && isomorph_default.utimes && isomorph_default.readdir && isomorph_default.mkdir && isomorph_default.unlink && isomorph_default.homedir);
436
+ return !!(isomorph_default.hash && isomorph_default.gunzip && isomorph_default.gzip && isomorph_default.stat && isomorph_default.readFile && isomorph_default.writeFile && isomorph_default.utimes && isomorph_default.readdir && isomorph_default.mkdir && isomorph_default.unlink && isomorph_default.homedir);
435
437
  }
436
438
  var DiskCache = class {
437
439
  dir;
438
440
  max;
441
+ logWarnings;
439
442
  /**
440
443
  * Creates a new DiskCache instance.
441
444
  * @param options - Configuration options for the cache.
@@ -446,14 +449,11 @@ var DiskCache = class {
446
449
  }
447
450
  this.dir = options.cacheDir;
448
451
  this.max = options.max;
452
+ this.logWarnings = options.logWarnings ?? true;
449
453
  }
450
- /**
451
- * Gets the file path for a cache entry.
452
- * @param key - The cache key to get the path for.
453
- * @returns The full filesystem path for the cache entry.
454
- */
455
454
  getEntryPath(key) {
456
- return isomorph_default.pathJoin(this.dir, key);
455
+ const hashed = isomorph_default.hash(key);
456
+ return isomorph_default.pathJoin(this.dir, hashed);
457
457
  }
458
458
  /**
459
459
  * Retrieves a value from the cache.
@@ -461,7 +461,6 @@ var DiskCache = class {
461
461
  *
462
462
  * @param key - The key to look up in the cache.
463
463
  * @returns The cached value if found, undefined otherwise.
464
- * @throws If there is an error reading from the disk cache (except for file not found).
465
464
  */
466
465
  async get(key) {
467
466
  try {
@@ -473,7 +472,10 @@ var DiskCache = class {
473
472
  if (e.code === "ENOENT") {
474
473
  return void 0;
475
474
  }
476
- throw e;
475
+ if (this.logWarnings) {
476
+ console.warn("Failed to read from disk cache", e);
477
+ }
478
+ return void 0;
477
479
  }
478
480
  }
479
481
  /**
@@ -487,33 +489,35 @@ var DiskCache = class {
487
489
  await isomorph_default.mkdir(this.dir, { recursive: true });
488
490
  const filePath = this.getEntryPath(key);
489
491
  const data = await isomorph_default.gzip(JSON.stringify(value));
490
- await isomorph_default.writeFile(filePath, data);
491
- if (this.max) {
492
- const entries = await isomorph_default.readdir(this.dir);
493
- if (entries.length > this.max) {
494
- await this.evictOldest(entries);
495
- }
492
+ try {
493
+ await isomorph_default.writeFile(filePath, data);
494
+ await this.evictOldestIfFull();
495
+ } catch (e) {
496
+ console.warn("Failed to write to disk cache", e);
497
+ return;
496
498
  }
497
499
  }
498
- /**
499
- * Evicts the oldest entries from the cache until it is under the maximum size.
500
- * @param entries - List of all cache entry filenames.
501
- */
502
- async evictOldest(entries) {
500
+ async evictOldestIfFull() {
501
+ if (!this.max) {
502
+ return;
503
+ }
504
+ const files = await isomorph_default.readdir(this.dir);
505
+ const paths = files.map((file) => isomorph_default.pathJoin(this.dir, file));
506
+ if (paths.length <= this.max) {
507
+ return;
508
+ }
503
509
  const stats = await Promise.all(
504
- entries.map(async (entry) => {
505
- const stat = await isomorph_default.stat(this.getEntryPath(entry));
510
+ paths.map(async (path) => {
511
+ const stat = await isomorph_default.stat(path);
506
512
  return {
507
- name: entry,
513
+ path,
508
514
  mtime: stat.mtime.getTime()
509
515
  };
510
516
  })
511
517
  );
512
518
  stats.sort((a, b) => a.mtime - b.mtime);
513
519
  const toRemove = stats.slice(0, stats.length - this.max);
514
- await Promise.all(
515
- toRemove.map((stat) => isomorph_default.unlink(this.getEntryPath(stat.name)))
516
- );
520
+ await Promise.all(toRemove.map((stat) => isomorph_default.unlink(stat.path)));
517
521
  }
518
522
  };
519
523
 
@@ -903,7 +907,7 @@ var BraintrustState = class _BraintrustState {
903
907
  const serializedParsed = loginSchema.safeParse(serialized);
904
908
  if (!serializedParsed.success) {
905
909
  throw new Error(
906
- `Cannot deserialize BraintrustState: ${serializedParsed.error.errors}`
910
+ `Cannot deserialize BraintrustState: ${serializedParsed.error.message}`
907
911
  );
908
912
  }
909
913
  const state = new _BraintrustState({ ...opts });
@@ -3106,17 +3110,17 @@ function extractAttachments(event, attachments) {
3106
3110
  extractAttachments(value, attachments);
3107
3111
  }
3108
3112
  }
3109
- function enrichAttachments(event) {
3113
+ function enrichAttachments(event, state) {
3110
3114
  for (const [key, value] of Object.entries(event)) {
3111
3115
  const parsedValue = import_typespecs2.attachmentReferenceSchema.safeParse(value);
3112
3116
  if (parsedValue.success) {
3113
- event[key] = new ReadonlyAttachment(parsedValue.data);
3117
+ event[key] = new ReadonlyAttachment(parsedValue.data, state);
3114
3118
  continue;
3115
3119
  }
3116
3120
  if (!(value instanceof Object)) {
3117
3121
  continue;
3118
3122
  }
3119
- enrichAttachments(value);
3123
+ enrichAttachments(value, state);
3120
3124
  }
3121
3125
  return event;
3122
3126
  }
@@ -3248,7 +3252,7 @@ var Experiment = class extends ObjectFetcher {
3248
3252
  // For type identification.
3249
3253
  kind = "experiment";
3250
3254
  constructor(state, lazyMetadata, dataset) {
3251
- super("experiment", void 0, enrichAttachments);
3255
+ super("experiment", void 0, (r) => enrichAttachments(r, state));
3252
3256
  this.lazyMetadata = lazyMetadata;
3253
3257
  this.dataset = dataset;
3254
3258
  this.lastStartTime = getCurrentUnixTimestamp();
@@ -3491,7 +3495,7 @@ var Experiment = class extends ObjectFetcher {
3491
3495
  };
3492
3496
  var ReadonlyExperiment = class extends ObjectFetcher {
3493
3497
  constructor(state, lazyMetadata) {
3494
- super("experiment", void 0, enrichAttachments);
3498
+ super("experiment", void 0, (r) => enrichAttachments(r, state));
3495
3499
  this.state = state;
3496
3500
  this.lazyMetadata = lazyMetadata;
3497
3501
  }
@@ -3804,7 +3808,7 @@ var Dataset = class extends ObjectFetcher {
3804
3808
  (r) => (
3805
3809
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
3806
3810
  (0, import_core2.ensureDatasetRecord)(
3807
- enrichAttachments(r),
3811
+ enrichAttachments(r, this.state),
3808
3812
  isLegacyDataset
3809
3813
  )
3810
3814
  ),
@@ -4140,6 +4144,7 @@ var Prompt = class _Prompt {
4140
4144
  }
4141
4145
  parsedPromptData;
4142
4146
  hasParsedPromptData = false;
4147
+ __braintrust_prompt_marker = true;
4143
4148
  get id() {
4144
4149
  return this.metadata.id;
4145
4150
  }
@@ -4161,6 +4166,9 @@ var Prompt = class _Prompt {
4161
4166
  get options() {
4162
4167
  return this.getParsedPromptData()?.options || {};
4163
4168
  }
4169
+ get promptData() {
4170
+ return this.getParsedPromptData();
4171
+ }
4164
4172
  /**
4165
4173
  * Build the prompt with the given formatting options. The args you pass in will
4166
4174
  * be forwarded to the mustache template that defines the prompt and rendered with
@@ -4328,6 +4336,20 @@ var Prompt = class _Prompt {
4328
4336
  }
4329
4337
  return this.parsedPromptData;
4330
4338
  }
4339
+ static isPrompt(data) {
4340
+ return typeof data === "object" && data !== null && "__braintrust_prompt_marker" in data;
4341
+ }
4342
+ static fromPromptData(name, promptData) {
4343
+ return new _Prompt(
4344
+ {
4345
+ name,
4346
+ slug: name,
4347
+ prompt_data: promptData
4348
+ },
4349
+ {},
4350
+ false
4351
+ );
4352
+ }
4331
4353
  };
4332
4354
  var TEST_API_KEY = "___TEST_API_KEY__THIS_IS_NOT_REAL___";
4333
4355
  function simulateLoginForTests() {
@@ -4359,6 +4381,16 @@ function configureBrowser() {
4359
4381
  }
4360
4382
  return process.env[name];
4361
4383
  };
4384
+ isomorph_default.hash = (data) => {
4385
+ let hash = 0;
4386
+ for (let i = 0; i < data.length; i++) {
4387
+ const char = data.charCodeAt(i);
4388
+ hash = (hash << 5) - hash + char;
4389
+ hash = hash & hash;
4390
+ }
4391
+ const hashHex = (hash >>> 0).toString(16).padStart(8, "0");
4392
+ return hashHex.repeat(8).substring(0, 64);
4393
+ };
4362
4394
  _internalSetInitialState();
4363
4395
  browserConfigured = true;
4364
4396
  }
@@ -4395,6 +4427,8 @@ __export(exports_browser_exports, {
4395
4427
  currentSpan: () => currentSpan,
4396
4428
  deserializePlainStringAsJSON: () => deserializePlainStringAsJSON,
4397
4429
  devNullWritableStream: () => devNullWritableStream,
4430
+ evaluatorDefinitionSchema: () => evaluatorDefinitionSchema,
4431
+ evaluatorDefinitionsSchema: () => evaluatorDefinitionsSchema,
4398
4432
  flush: () => flush,
4399
4433
  getSpanParentObject: () => getSpanParentObject,
4400
4434
  init: () => init,
@@ -5138,6 +5172,47 @@ var WrapperStream = class {
5138
5172
  }
5139
5173
  };
5140
5174
 
5175
+ // dev/types.ts
5176
+ var import_typespecs4 = require("@braintrust/core/typespecs");
5177
+ var import_zod3 = require("zod");
5178
+ var evalBodySchema = import_zod3.z.object({
5179
+ name: import_zod3.z.string(),
5180
+ parameters: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()).nullish(),
5181
+ data: import_typespecs4.runEvalSchema.shape.data,
5182
+ scores: import_zod3.z.array(
5183
+ import_zod3.z.object({
5184
+ function_id: import_typespecs4.functionIdSchema,
5185
+ name: import_zod3.z.string()
5186
+ })
5187
+ ).nullish(),
5188
+ parent: import_typespecs4.invokeParent.optional(),
5189
+ stream: import_zod3.z.boolean().optional()
5190
+ });
5191
+ var evalParametersSerializedSchema = import_zod3.z.record(
5192
+ import_zod3.z.string(),
5193
+ import_zod3.z.union([
5194
+ import_zod3.z.object({
5195
+ type: import_zod3.z.literal("prompt"),
5196
+ default: import_typespecs4.promptDataSchema.optional(),
5197
+ description: import_zod3.z.string().optional()
5198
+ }),
5199
+ import_zod3.z.object({
5200
+ type: import_zod3.z.literal("data"),
5201
+ schema: import_zod3.z.record(import_zod3.z.unknown()),
5202
+ // JSON Schema
5203
+ default: import_zod3.z.unknown().optional(),
5204
+ description: import_zod3.z.string().optional()
5205
+ })
5206
+ ])
5207
+ );
5208
+ var evaluatorDefinitionSchema = import_zod3.z.object({
5209
+ parameters: evalParametersSerializedSchema.optional()
5210
+ });
5211
+ var evaluatorDefinitionsSchema = import_zod3.z.record(
5212
+ import_zod3.z.string(),
5213
+ evaluatorDefinitionSchema
5214
+ );
5215
+
5141
5216
  // src/browser.ts
5142
5217
  configureBrowser();
5143
5218
  var browser_default = exports_browser_exports;
@@ -5172,6 +5247,8 @@ var browser_default = exports_browser_exports;
5172
5247
  currentSpan,
5173
5248
  deserializePlainStringAsJSON,
5174
5249
  devNullWritableStream,
5250
+ evaluatorDefinitionSchema,
5251
+ evaluatorDefinitionsSchema,
5175
5252
  flush,
5176
5253
  getSpanParentObject,
5177
5254
  init,
package/dist/browser.mjs CHANGED
@@ -341,11 +341,11 @@ function createFinalValuePassThroughStream(onFinal, onError) {
341
341
  break;
342
342
  default:
343
343
  const _type = chunkType;
344
- throw new Error(`Unknown chunk type ${_type}`);
344
+ onError(`Unknown chunk type: ${_type}`);
345
345
  }
346
346
  controller.enqueue(chunk);
347
347
  } else {
348
- throw new Error(`Unknown chunk type ${chunk}`);
348
+ onError(`Unknown chunk type ${JSON.stringify(chunk)}`);
349
349
  }
350
350
  },
351
351
  flush(controller) {
@@ -376,11 +376,12 @@ function devNullWritableStream() {
376
376
 
377
377
  // src/prompt-cache/disk-cache.ts
378
378
  function canUseDiskCache() {
379
- return !!(isomorph_default.gunzip && isomorph_default.gzip && isomorph_default.stat && isomorph_default.readFile && isomorph_default.writeFile && isomorph_default.utimes && isomorph_default.readdir && isomorph_default.mkdir && isomorph_default.unlink && isomorph_default.homedir);
379
+ return !!(isomorph_default.hash && isomorph_default.gunzip && isomorph_default.gzip && isomorph_default.stat && isomorph_default.readFile && isomorph_default.writeFile && isomorph_default.utimes && isomorph_default.readdir && isomorph_default.mkdir && isomorph_default.unlink && isomorph_default.homedir);
380
380
  }
381
381
  var DiskCache = class {
382
382
  dir;
383
383
  max;
384
+ logWarnings;
384
385
  /**
385
386
  * Creates a new DiskCache instance.
386
387
  * @param options - Configuration options for the cache.
@@ -391,14 +392,11 @@ var DiskCache = class {
391
392
  }
392
393
  this.dir = options.cacheDir;
393
394
  this.max = options.max;
395
+ this.logWarnings = options.logWarnings ?? true;
394
396
  }
395
- /**
396
- * Gets the file path for a cache entry.
397
- * @param key - The cache key to get the path for.
398
- * @returns The full filesystem path for the cache entry.
399
- */
400
397
  getEntryPath(key) {
401
- return isomorph_default.pathJoin(this.dir, key);
398
+ const hashed = isomorph_default.hash(key);
399
+ return isomorph_default.pathJoin(this.dir, hashed);
402
400
  }
403
401
  /**
404
402
  * Retrieves a value from the cache.
@@ -406,7 +404,6 @@ var DiskCache = class {
406
404
  *
407
405
  * @param key - The key to look up in the cache.
408
406
  * @returns The cached value if found, undefined otherwise.
409
- * @throws If there is an error reading from the disk cache (except for file not found).
410
407
  */
411
408
  async get(key) {
412
409
  try {
@@ -418,7 +415,10 @@ var DiskCache = class {
418
415
  if (e.code === "ENOENT") {
419
416
  return void 0;
420
417
  }
421
- throw e;
418
+ if (this.logWarnings) {
419
+ console.warn("Failed to read from disk cache", e);
420
+ }
421
+ return void 0;
422
422
  }
423
423
  }
424
424
  /**
@@ -432,33 +432,35 @@ var DiskCache = class {
432
432
  await isomorph_default.mkdir(this.dir, { recursive: true });
433
433
  const filePath = this.getEntryPath(key);
434
434
  const data = await isomorph_default.gzip(JSON.stringify(value));
435
- await isomorph_default.writeFile(filePath, data);
436
- if (this.max) {
437
- const entries = await isomorph_default.readdir(this.dir);
438
- if (entries.length > this.max) {
439
- await this.evictOldest(entries);
440
- }
435
+ try {
436
+ await isomorph_default.writeFile(filePath, data);
437
+ await this.evictOldestIfFull();
438
+ } catch (e) {
439
+ console.warn("Failed to write to disk cache", e);
440
+ return;
441
441
  }
442
442
  }
443
- /**
444
- * Evicts the oldest entries from the cache until it is under the maximum size.
445
- * @param entries - List of all cache entry filenames.
446
- */
447
- async evictOldest(entries) {
443
+ async evictOldestIfFull() {
444
+ if (!this.max) {
445
+ return;
446
+ }
447
+ const files = await isomorph_default.readdir(this.dir);
448
+ const paths = files.map((file) => isomorph_default.pathJoin(this.dir, file));
449
+ if (paths.length <= this.max) {
450
+ return;
451
+ }
448
452
  const stats = await Promise.all(
449
- entries.map(async (entry) => {
450
- const stat = await isomorph_default.stat(this.getEntryPath(entry));
453
+ paths.map(async (path) => {
454
+ const stat = await isomorph_default.stat(path);
451
455
  return {
452
- name: entry,
456
+ path,
453
457
  mtime: stat.mtime.getTime()
454
458
  };
455
459
  })
456
460
  );
457
461
  stats.sort((a, b) => a.mtime - b.mtime);
458
462
  const toRemove = stats.slice(0, stats.length - this.max);
459
- await Promise.all(
460
- toRemove.map((stat) => isomorph_default.unlink(this.getEntryPath(stat.name)))
461
- );
463
+ await Promise.all(toRemove.map((stat) => isomorph_default.unlink(stat.path)));
462
464
  }
463
465
  };
464
466
 
@@ -848,7 +850,7 @@ var BraintrustState = class _BraintrustState {
848
850
  const serializedParsed = loginSchema.safeParse(serialized);
849
851
  if (!serializedParsed.success) {
850
852
  throw new Error(
851
- `Cannot deserialize BraintrustState: ${serializedParsed.error.errors}`
853
+ `Cannot deserialize BraintrustState: ${serializedParsed.error.message}`
852
854
  );
853
855
  }
854
856
  const state = new _BraintrustState({ ...opts });
@@ -3051,17 +3053,17 @@ function extractAttachments(event, attachments) {
3051
3053
  extractAttachments(value, attachments);
3052
3054
  }
3053
3055
  }
3054
- function enrichAttachments(event) {
3056
+ function enrichAttachments(event, state) {
3055
3057
  for (const [key, value] of Object.entries(event)) {
3056
3058
  const parsedValue = attachmentReferenceSchema.safeParse(value);
3057
3059
  if (parsedValue.success) {
3058
- event[key] = new ReadonlyAttachment(parsedValue.data);
3060
+ event[key] = new ReadonlyAttachment(parsedValue.data, state);
3059
3061
  continue;
3060
3062
  }
3061
3063
  if (!(value instanceof Object)) {
3062
3064
  continue;
3063
3065
  }
3064
- enrichAttachments(value);
3066
+ enrichAttachments(value, state);
3065
3067
  }
3066
3068
  return event;
3067
3069
  }
@@ -3193,7 +3195,7 @@ var Experiment = class extends ObjectFetcher {
3193
3195
  // For type identification.
3194
3196
  kind = "experiment";
3195
3197
  constructor(state, lazyMetadata, dataset) {
3196
- super("experiment", void 0, enrichAttachments);
3198
+ super("experiment", void 0, (r) => enrichAttachments(r, state));
3197
3199
  this.lazyMetadata = lazyMetadata;
3198
3200
  this.dataset = dataset;
3199
3201
  this.lastStartTime = getCurrentUnixTimestamp();
@@ -3436,7 +3438,7 @@ var Experiment = class extends ObjectFetcher {
3436
3438
  };
3437
3439
  var ReadonlyExperiment = class extends ObjectFetcher {
3438
3440
  constructor(state, lazyMetadata) {
3439
- super("experiment", void 0, enrichAttachments);
3441
+ super("experiment", void 0, (r) => enrichAttachments(r, state));
3440
3442
  this.state = state;
3441
3443
  this.lazyMetadata = lazyMetadata;
3442
3444
  }
@@ -3749,7 +3751,7 @@ var Dataset = class extends ObjectFetcher {
3749
3751
  (r) => (
3750
3752
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
3751
3753
  ensureDatasetRecord(
3752
- enrichAttachments(r),
3754
+ enrichAttachments(r, this.state),
3753
3755
  isLegacyDataset
3754
3756
  )
3755
3757
  ),
@@ -4085,6 +4087,7 @@ var Prompt = class _Prompt {
4085
4087
  }
4086
4088
  parsedPromptData;
4087
4089
  hasParsedPromptData = false;
4090
+ __braintrust_prompt_marker = true;
4088
4091
  get id() {
4089
4092
  return this.metadata.id;
4090
4093
  }
@@ -4106,6 +4109,9 @@ var Prompt = class _Prompt {
4106
4109
  get options() {
4107
4110
  return this.getParsedPromptData()?.options || {};
4108
4111
  }
4112
+ get promptData() {
4113
+ return this.getParsedPromptData();
4114
+ }
4109
4115
  /**
4110
4116
  * Build the prompt with the given formatting options. The args you pass in will
4111
4117
  * be forwarded to the mustache template that defines the prompt and rendered with
@@ -4273,6 +4279,20 @@ var Prompt = class _Prompt {
4273
4279
  }
4274
4280
  return this.parsedPromptData;
4275
4281
  }
4282
+ static isPrompt(data) {
4283
+ return typeof data === "object" && data !== null && "__braintrust_prompt_marker" in data;
4284
+ }
4285
+ static fromPromptData(name, promptData) {
4286
+ return new _Prompt(
4287
+ {
4288
+ name,
4289
+ slug: name,
4290
+ prompt_data: promptData
4291
+ },
4292
+ {},
4293
+ false
4294
+ );
4295
+ }
4276
4296
  };
4277
4297
  var TEST_API_KEY = "___TEST_API_KEY__THIS_IS_NOT_REAL___";
4278
4298
  function simulateLoginForTests() {
@@ -4304,6 +4324,16 @@ function configureBrowser() {
4304
4324
  }
4305
4325
  return process.env[name];
4306
4326
  };
4327
+ isomorph_default.hash = (data) => {
4328
+ let hash = 0;
4329
+ for (let i = 0; i < data.length; i++) {
4330
+ const char = data.charCodeAt(i);
4331
+ hash = (hash << 5) - hash + char;
4332
+ hash = hash & hash;
4333
+ }
4334
+ const hashHex = (hash >>> 0).toString(16).padStart(8, "0");
4335
+ return hashHex.repeat(8).substring(0, 64);
4336
+ };
4307
4337
  _internalSetInitialState();
4308
4338
  browserConfigured = true;
4309
4339
  }
@@ -4340,6 +4370,8 @@ __export(exports_browser_exports, {
4340
4370
  currentSpan: () => currentSpan,
4341
4371
  deserializePlainStringAsJSON: () => deserializePlainStringAsJSON,
4342
4372
  devNullWritableStream: () => devNullWritableStream,
4373
+ evaluatorDefinitionSchema: () => evaluatorDefinitionSchema,
4374
+ evaluatorDefinitionsSchema: () => evaluatorDefinitionsSchema,
4343
4375
  flush: () => flush,
4344
4376
  getSpanParentObject: () => getSpanParentObject,
4345
4377
  init: () => init,
@@ -5085,6 +5117,52 @@ var WrapperStream = class {
5085
5117
  }
5086
5118
  };
5087
5119
 
5120
+ // dev/types.ts
5121
+ import {
5122
+ functionIdSchema as functionIdSchema2,
5123
+ invokeParent,
5124
+ runEvalSchema,
5125
+ promptDataSchema as promptDataSchema2
5126
+ } from "@braintrust/core/typespecs";
5127
+ import { z as z3 } from "zod";
5128
+ var evalBodySchema = z3.object({
5129
+ name: z3.string(),
5130
+ parameters: z3.record(z3.string(), z3.unknown()).nullish(),
5131
+ data: runEvalSchema.shape.data,
5132
+ scores: z3.array(
5133
+ z3.object({
5134
+ function_id: functionIdSchema2,
5135
+ name: z3.string()
5136
+ })
5137
+ ).nullish(),
5138
+ parent: invokeParent.optional(),
5139
+ stream: z3.boolean().optional()
5140
+ });
5141
+ var evalParametersSerializedSchema = z3.record(
5142
+ z3.string(),
5143
+ z3.union([
5144
+ z3.object({
5145
+ type: z3.literal("prompt"),
5146
+ default: promptDataSchema2.optional(),
5147
+ description: z3.string().optional()
5148
+ }),
5149
+ z3.object({
5150
+ type: z3.literal("data"),
5151
+ schema: z3.record(z3.unknown()),
5152
+ // JSON Schema
5153
+ default: z3.unknown().optional(),
5154
+ description: z3.string().optional()
5155
+ })
5156
+ ])
5157
+ );
5158
+ var evaluatorDefinitionSchema = z3.object({
5159
+ parameters: evalParametersSerializedSchema.optional()
5160
+ });
5161
+ var evaluatorDefinitionsSchema = z3.record(
5162
+ z3.string(),
5163
+ evaluatorDefinitionSchema
5164
+ );
5165
+
5088
5166
  // src/browser.ts
5089
5167
  configureBrowser();
5090
5168
  var browser_default = exports_browser_exports;
@@ -5119,6 +5197,8 @@ export {
5119
5197
  browser_default as default,
5120
5198
  deserializePlainStringAsJSON,
5121
5199
  devNullWritableStream,
5200
+ evaluatorDefinitionSchema,
5201
+ evaluatorDefinitionsSchema,
5122
5202
  flush,
5123
5203
  getSpanParentObject,
5124
5204
  init,