braintrust 0.3.7 → 0.4.0

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/index.mjs CHANGED
@@ -1528,7 +1528,7 @@ var init_BatchSpanProcessor = __esm({
1528
1528
  });
1529
1529
 
1530
1530
  // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/RandomIdGenerator.js
1531
- function getIdGenerator(bytes) {
1531
+ function getIdGenerator2(bytes) {
1532
1532
  return function generateId() {
1533
1533
  for (let i = 0; i < bytes / 4; i++) {
1534
1534
  SHARED_BUFFER.writeUInt32BE(Math.random() * 2 ** 32 >>> 0, i * 4);
@@ -1554,12 +1554,12 @@ var init_RandomIdGenerator = __esm({
1554
1554
  * Returns a random 16-byte trace ID formatted/encoded as a 32 lowercase hex
1555
1555
  * characters corresponding to 128 bits.
1556
1556
  */
1557
- generateTraceId = getIdGenerator(TRACE_ID_BYTES);
1557
+ generateTraceId = getIdGenerator2(TRACE_ID_BYTES);
1558
1558
  /**
1559
1559
  * Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex
1560
1560
  * characters corresponding to 64 bits.
1561
1561
  */
1562
- generateSpanId = getIdGenerator(SPAN_ID_BYTES);
1562
+ generateSpanId = getIdGenerator2(SPAN_ID_BYTES);
1563
1563
  };
1564
1564
  SHARED_BUFFER = Buffer.allocUnsafe(TRACE_ID_BYTES);
1565
1565
  }
@@ -3440,7 +3440,7 @@ function getCallerLocation() {
3440
3440
  }
3441
3441
 
3442
3442
  // src/logger.ts
3443
- import { v4 as uuidv4 } from "uuid";
3443
+ import { v4 as uuidv42 } from "uuid";
3444
3444
 
3445
3445
  // src/queue.ts
3446
3446
  var DEFAULT_QUEUE_SIZE = 15e3;
@@ -3498,6 +3498,44 @@ var Queue = class {
3498
3498
  }
3499
3499
  };
3500
3500
 
3501
+ // src/id-gen.ts
3502
+ import { v4 as uuidv4 } from "uuid";
3503
+ function generateHexId(bytes) {
3504
+ let result = "";
3505
+ for (let i = 0; i < bytes; i++) {
3506
+ result += Math.floor(Math.random() * 256).toString(16).padStart(2, "0");
3507
+ }
3508
+ return result;
3509
+ }
3510
+ var IDGenerator = class {
3511
+ };
3512
+ var UUIDGenerator = class extends IDGenerator {
3513
+ getSpanId() {
3514
+ return uuidv4();
3515
+ }
3516
+ getTraceId() {
3517
+ return uuidv4();
3518
+ }
3519
+ shareRootSpanId() {
3520
+ return true;
3521
+ }
3522
+ };
3523
+ var OTELIDGenerator = class extends IDGenerator {
3524
+ getSpanId() {
3525
+ return generateHexId(8);
3526
+ }
3527
+ getTraceId() {
3528
+ return generateHexId(16);
3529
+ }
3530
+ shareRootSpanId() {
3531
+ return false;
3532
+ }
3533
+ };
3534
+ function getIdGenerator() {
3535
+ const useOtel = typeof process !== "undefined" && process.env?.BRAINTRUST_OTEL_COMPAT?.toLowerCase() === "true";
3536
+ return useOtel ? new OTELIDGenerator() : new UUIDGenerator();
3537
+ }
3538
+
3501
3539
  // util/db_fields.ts
3502
3540
  var TRANSACTION_ID_FIELD = "_xact_id";
3503
3541
  var IS_MERGE_FIELD = "_is_merge";
@@ -4445,6 +4483,41 @@ function _urljoin(...parts) {
4445
4483
  ).filter((x) => x.trim() !== "").join("/");
4446
4484
  }
4447
4485
 
4486
+ // util/span_identifier_v4.ts
4487
+ import { z as z4 } from "zod/v3";
4488
+ var ENCODING_VERSION_NUMBER_V4 = 4;
4489
+ var INVALID_ENCODING_ERRMSG_V4 = `SpanComponents string is not properly encoded. This library only supports encoding versions up to ${ENCODING_VERSION_NUMBER_V4}. Please make sure the SDK library used to decode the SpanComponents is at least as new as any library used to encode it.`;
4490
+ var spanComponentsV4Schema = z4.object({
4491
+ object_type: spanObjectTypeV3EnumSchema,
4492
+ propagated_event: z4.record(z4.unknown()).nullish()
4493
+ }).and(
4494
+ z4.union([
4495
+ // Must provide one or the other.
4496
+ z4.object({
4497
+ object_id: z4.string().nullish(),
4498
+ compute_object_metadata_args: z4.optional(z4.null())
4499
+ }),
4500
+ z4.object({
4501
+ object_id: z4.optional(z4.null()),
4502
+ compute_object_metadata_args: z4.record(z4.unknown())
4503
+ })
4504
+ ])
4505
+ ).and(
4506
+ z4.union([
4507
+ // Either all of these must be provided or none.
4508
+ z4.object({
4509
+ row_id: z4.string(),
4510
+ span_id: z4.string(),
4511
+ root_span_id: z4.string()
4512
+ }),
4513
+ z4.object({
4514
+ row_id: z4.optional(z4.null()),
4515
+ span_id: z4.optional(z4.null()),
4516
+ root_span_id: z4.optional(z4.null())
4517
+ })
4518
+ ])
4519
+ );
4520
+
4448
4521
  // util/git_fields.ts
4449
4522
  function mergeGitMetadataSettings(s1, s2) {
4450
4523
  if (s1.collect === "all") {
@@ -4485,12 +4558,12 @@ function loadPrettyXact(encodedHex) {
4485
4558
  }
4486
4559
 
4487
4560
  // util/zod_util.ts
4488
- import { z as z4 } from "zod/v3";
4561
+ import { z as z5 } from "zod/v3";
4489
4562
 
4490
4563
  // src/generated_types.ts
4491
- import { z as z5 } from "zod/v3";
4492
- var AclObjectType = z5.union([
4493
- z5.enum([
4564
+ import { z as z6 } from "zod/v3";
4565
+ var AclObjectType = z6.union([
4566
+ z6.enum([
4494
4567
  "organization",
4495
4568
  "project",
4496
4569
  "experiment",
@@ -4503,9 +4576,9 @@ var AclObjectType = z5.union([
4503
4576
  "project_log",
4504
4577
  "org_project"
4505
4578
  ]),
4506
- z5.null()
4579
+ z6.null()
4507
4580
  ]);
4508
- var Permission = z5.enum([
4581
+ var Permission = z6.enum([
4509
4582
  "create",
4510
4583
  "read",
4511
4584
  "update",
@@ -4515,310 +4588,310 @@ var Permission = z5.enum([
4515
4588
  "update_acls",
4516
4589
  "delete_acls"
4517
4590
  ]);
4518
- var Acl = z5.object({
4519
- id: z5.string().uuid(),
4520
- object_type: AclObjectType.and(z5.string()),
4521
- object_id: z5.string().uuid(),
4522
- user_id: z5.union([z5.string(), z5.null()]).optional(),
4523
- group_id: z5.union([z5.string(), z5.null()]).optional(),
4524
- permission: Permission.and(z5.union([z5.string(), z5.null()])).optional(),
4525
- restrict_object_type: AclObjectType.and(z5.unknown()).optional(),
4526
- role_id: z5.union([z5.string(), z5.null()]).optional(),
4527
- _object_org_id: z5.string().uuid(),
4528
- created: z5.union([z5.string(), z5.null()]).optional()
4529
- });
4530
- var AISecret = z5.object({
4531
- id: z5.string().uuid(),
4532
- created: z5.union([z5.string(), z5.null()]).optional(),
4533
- updated_at: z5.union([z5.string(), z5.null()]).optional(),
4534
- org_id: z5.string().uuid(),
4535
- name: z5.string(),
4536
- type: z5.union([z5.string(), z5.null()]).optional(),
4537
- metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
4538
- preview_secret: z5.union([z5.string(), z5.null()]).optional()
4539
- });
4540
- var ResponseFormatJsonSchema = z5.object({
4541
- name: z5.string(),
4542
- description: z5.string().optional(),
4543
- schema: z5.union([z5.object({}).partial().passthrough(), z5.string()]).optional(),
4544
- strict: z5.union([z5.boolean(), z5.null()]).optional()
4545
- });
4546
- var ResponseFormatNullish = z5.union([
4547
- z5.object({ type: z5.literal("json_object") }),
4548
- z5.object({
4549
- type: z5.literal("json_schema"),
4591
+ var Acl = z6.object({
4592
+ id: z6.string().uuid(),
4593
+ object_type: AclObjectType.and(z6.string()),
4594
+ object_id: z6.string().uuid(),
4595
+ user_id: z6.union([z6.string(), z6.null()]).optional(),
4596
+ group_id: z6.union([z6.string(), z6.null()]).optional(),
4597
+ permission: Permission.and(z6.union([z6.string(), z6.null()])).optional(),
4598
+ restrict_object_type: AclObjectType.and(z6.unknown()).optional(),
4599
+ role_id: z6.union([z6.string(), z6.null()]).optional(),
4600
+ _object_org_id: z6.string().uuid(),
4601
+ created: z6.union([z6.string(), z6.null()]).optional()
4602
+ });
4603
+ var AISecret = z6.object({
4604
+ id: z6.string().uuid(),
4605
+ created: z6.union([z6.string(), z6.null()]).optional(),
4606
+ updated_at: z6.union([z6.string(), z6.null()]).optional(),
4607
+ org_id: z6.string().uuid(),
4608
+ name: z6.string(),
4609
+ type: z6.union([z6.string(), z6.null()]).optional(),
4610
+ metadata: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional(),
4611
+ preview_secret: z6.union([z6.string(), z6.null()]).optional()
4612
+ });
4613
+ var ResponseFormatJsonSchema = z6.object({
4614
+ name: z6.string(),
4615
+ description: z6.string().optional(),
4616
+ schema: z6.union([z6.object({}).partial().passthrough(), z6.string()]).optional(),
4617
+ strict: z6.union([z6.boolean(), z6.null()]).optional()
4618
+ });
4619
+ var ResponseFormatNullish = z6.union([
4620
+ z6.object({ type: z6.literal("json_object") }),
4621
+ z6.object({
4622
+ type: z6.literal("json_schema"),
4550
4623
  json_schema: ResponseFormatJsonSchema
4551
4624
  }),
4552
- z5.object({ type: z5.literal("text") }),
4553
- z5.null()
4625
+ z6.object({ type: z6.literal("text") }),
4626
+ z6.null()
4554
4627
  ]);
4555
- var AnyModelParams = z5.object({
4556
- temperature: z5.number().optional(),
4557
- top_p: z5.number().optional(),
4558
- max_tokens: z5.number(),
4559
- max_completion_tokens: z5.number().optional(),
4560
- frequency_penalty: z5.number().optional(),
4561
- presence_penalty: z5.number().optional(),
4628
+ var AnyModelParams = z6.object({
4629
+ temperature: z6.number().optional(),
4630
+ top_p: z6.number().optional(),
4631
+ max_tokens: z6.number(),
4632
+ max_completion_tokens: z6.number().optional(),
4633
+ frequency_penalty: z6.number().optional(),
4634
+ presence_penalty: z6.number().optional(),
4562
4635
  response_format: ResponseFormatNullish.optional(),
4563
- tool_choice: z5.union([
4564
- z5.literal("auto"),
4565
- z5.literal("none"),
4566
- z5.literal("required"),
4567
- z5.object({
4568
- type: z5.literal("function"),
4569
- function: z5.object({ name: z5.string() })
4636
+ tool_choice: z6.union([
4637
+ z6.literal("auto"),
4638
+ z6.literal("none"),
4639
+ z6.literal("required"),
4640
+ z6.object({
4641
+ type: z6.literal("function"),
4642
+ function: z6.object({ name: z6.string() })
4570
4643
  })
4571
4644
  ]).optional(),
4572
- function_call: z5.union([
4573
- z5.literal("auto"),
4574
- z5.literal("none"),
4575
- z5.object({ name: z5.string() })
4645
+ function_call: z6.union([
4646
+ z6.literal("auto"),
4647
+ z6.literal("none"),
4648
+ z6.object({ name: z6.string() })
4576
4649
  ]).optional(),
4577
- n: z5.number().optional(),
4578
- stop: z5.array(z5.string()).optional(),
4579
- reasoning_effort: z5.enum(["minimal", "low", "medium", "high"]).optional(),
4580
- verbosity: z5.enum(["low", "medium", "high"]).optional(),
4581
- top_k: z5.number().optional(),
4582
- stop_sequences: z5.array(z5.string()).optional(),
4583
- max_tokens_to_sample: z5.number().optional(),
4584
- maxOutputTokens: z5.number().optional(),
4585
- topP: z5.number().optional(),
4586
- topK: z5.number().optional(),
4587
- use_cache: z5.boolean().optional()
4588
- });
4589
- var ApiKey = z5.object({
4590
- id: z5.string().uuid(),
4591
- created: z5.union([z5.string(), z5.null()]).optional(),
4592
- name: z5.string(),
4593
- preview_name: z5.string(),
4594
- user_id: z5.union([z5.string(), z5.null()]).optional(),
4595
- user_email: z5.union([z5.string(), z5.null()]).optional(),
4596
- user_given_name: z5.union([z5.string(), z5.null()]).optional(),
4597
- user_family_name: z5.union([z5.string(), z5.null()]).optional(),
4598
- org_id: z5.union([z5.string(), z5.null()]).optional()
4599
- });
4600
- var AsyncScoringState = z5.union([
4601
- z5.object({
4602
- status: z5.literal("enabled"),
4603
- token: z5.string(),
4604
- function_ids: z5.array(z5.unknown()).min(1),
4605
- skip_logging: z5.union([z5.boolean(), z5.null()]).optional()
4650
+ n: z6.number().optional(),
4651
+ stop: z6.array(z6.string()).optional(),
4652
+ reasoning_effort: z6.enum(["minimal", "low", "medium", "high"]).optional(),
4653
+ verbosity: z6.enum(["low", "medium", "high"]).optional(),
4654
+ top_k: z6.number().optional(),
4655
+ stop_sequences: z6.array(z6.string()).optional(),
4656
+ max_tokens_to_sample: z6.number().optional(),
4657
+ maxOutputTokens: z6.number().optional(),
4658
+ topP: z6.number().optional(),
4659
+ topK: z6.number().optional(),
4660
+ use_cache: z6.boolean().optional()
4661
+ });
4662
+ var ApiKey = z6.object({
4663
+ id: z6.string().uuid(),
4664
+ created: z6.union([z6.string(), z6.null()]).optional(),
4665
+ name: z6.string(),
4666
+ preview_name: z6.string(),
4667
+ user_id: z6.union([z6.string(), z6.null()]).optional(),
4668
+ user_email: z6.union([z6.string(), z6.null()]).optional(),
4669
+ user_given_name: z6.union([z6.string(), z6.null()]).optional(),
4670
+ user_family_name: z6.union([z6.string(), z6.null()]).optional(),
4671
+ org_id: z6.union([z6.string(), z6.null()]).optional()
4672
+ });
4673
+ var AsyncScoringState = z6.union([
4674
+ z6.object({
4675
+ status: z6.literal("enabled"),
4676
+ token: z6.string(),
4677
+ function_ids: z6.array(z6.unknown()).min(1),
4678
+ skip_logging: z6.union([z6.boolean(), z6.null()]).optional()
4606
4679
  }),
4607
- z5.object({ status: z5.literal("disabled") }),
4608
- z5.null(),
4609
- z5.null()
4680
+ z6.object({ status: z6.literal("disabled") }),
4681
+ z6.null(),
4682
+ z6.null()
4610
4683
  ]);
4611
- var AsyncScoringControl = z5.union([
4612
- z5.object({ kind: z5.literal("score_update"), token: z5.string() }),
4613
- z5.object({ kind: z5.literal("state_override"), state: AsyncScoringState }),
4614
- z5.object({ kind: z5.literal("state_force_reselect") }),
4615
- z5.object({ kind: z5.literal("state_enabled_force_rescore") })
4684
+ var AsyncScoringControl = z6.union([
4685
+ z6.object({ kind: z6.literal("score_update"), token: z6.string() }),
4686
+ z6.object({ kind: z6.literal("state_override"), state: AsyncScoringState }),
4687
+ z6.object({ kind: z6.literal("state_force_reselect") }),
4688
+ z6.object({ kind: z6.literal("state_enabled_force_rescore") })
4616
4689
  ]);
4617
- var BraintrustAttachmentReference = z5.object({
4618
- type: z5.literal("braintrust_attachment"),
4619
- filename: z5.string().min(1),
4620
- content_type: z5.string().min(1),
4621
- key: z5.string().min(1)
4622
- });
4623
- var ExternalAttachmentReference = z5.object({
4624
- type: z5.literal("external_attachment"),
4625
- filename: z5.string().min(1),
4626
- content_type: z5.string().min(1),
4627
- url: z5.string().min(1)
4628
- });
4629
- var AttachmentReference = z5.discriminatedUnion("type", [
4690
+ var BraintrustAttachmentReference = z6.object({
4691
+ type: z6.literal("braintrust_attachment"),
4692
+ filename: z6.string().min(1),
4693
+ content_type: z6.string().min(1),
4694
+ key: z6.string().min(1)
4695
+ });
4696
+ var ExternalAttachmentReference = z6.object({
4697
+ type: z6.literal("external_attachment"),
4698
+ filename: z6.string().min(1),
4699
+ content_type: z6.string().min(1),
4700
+ url: z6.string().min(1)
4701
+ });
4702
+ var AttachmentReference = z6.discriminatedUnion("type", [
4630
4703
  BraintrustAttachmentReference,
4631
4704
  ExternalAttachmentReference
4632
4705
  ]);
4633
- var UploadStatus = z5.enum(["uploading", "done", "error"]);
4634
- var AttachmentStatus = z5.object({
4706
+ var UploadStatus = z6.enum(["uploading", "done", "error"]);
4707
+ var AttachmentStatus = z6.object({
4635
4708
  upload_status: UploadStatus,
4636
- error_message: z5.string().optional()
4637
- });
4638
- var BraintrustModelParams = z5.object({ use_cache: z5.boolean() }).partial();
4639
- var CallEvent = z5.union([
4640
- z5.object({
4641
- id: z5.string().optional(),
4642
- data: z5.string(),
4643
- event: z5.literal("text_delta")
4709
+ error_message: z6.string().optional()
4710
+ });
4711
+ var BraintrustModelParams = z6.object({ use_cache: z6.boolean() }).partial();
4712
+ var CallEvent = z6.union([
4713
+ z6.object({
4714
+ id: z6.string().optional(),
4715
+ data: z6.string(),
4716
+ event: z6.literal("text_delta")
4644
4717
  }),
4645
- z5.object({
4646
- id: z5.string().optional(),
4647
- data: z5.string(),
4648
- event: z5.literal("reasoning_delta")
4718
+ z6.object({
4719
+ id: z6.string().optional(),
4720
+ data: z6.string(),
4721
+ event: z6.literal("reasoning_delta")
4649
4722
  }),
4650
- z5.object({
4651
- id: z5.string().optional(),
4652
- data: z5.string(),
4653
- event: z5.literal("json_delta")
4723
+ z6.object({
4724
+ id: z6.string().optional(),
4725
+ data: z6.string(),
4726
+ event: z6.literal("json_delta")
4654
4727
  }),
4655
- z5.object({
4656
- id: z5.string().optional(),
4657
- data: z5.string(),
4658
- event: z5.literal("progress")
4728
+ z6.object({
4729
+ id: z6.string().optional(),
4730
+ data: z6.string(),
4731
+ event: z6.literal("progress")
4659
4732
  }),
4660
- z5.object({
4661
- id: z5.string().optional(),
4662
- data: z5.string(),
4663
- event: z5.literal("error")
4733
+ z6.object({
4734
+ id: z6.string().optional(),
4735
+ data: z6.string(),
4736
+ event: z6.literal("error")
4664
4737
  }),
4665
- z5.object({
4666
- id: z5.string().optional(),
4667
- data: z5.string(),
4668
- event: z5.literal("console")
4738
+ z6.object({
4739
+ id: z6.string().optional(),
4740
+ data: z6.string(),
4741
+ event: z6.literal("console")
4669
4742
  }),
4670
- z5.object({
4671
- id: z5.string().optional(),
4672
- event: z5.literal("start"),
4673
- data: z5.literal("")
4743
+ z6.object({
4744
+ id: z6.string().optional(),
4745
+ event: z6.literal("start"),
4746
+ data: z6.literal("")
4674
4747
  }),
4675
- z5.object({
4676
- id: z5.string().optional(),
4677
- event: z5.literal("done"),
4678
- data: z5.literal("")
4748
+ z6.object({
4749
+ id: z6.string().optional(),
4750
+ event: z6.literal("done"),
4751
+ data: z6.literal("")
4679
4752
  })
4680
4753
  ]);
4681
- var ChatCompletionContentPartTextWithTitle = z5.object({
4682
- text: z5.string().default(""),
4683
- type: z5.literal("text"),
4684
- cache_control: z5.object({ type: z5.literal("ephemeral") }).optional()
4685
- });
4686
- var ChatCompletionContentPartImageWithTitle = z5.object({
4687
- image_url: z5.object({
4688
- url: z5.string(),
4689
- detail: z5.union([z5.literal("auto"), z5.literal("low"), z5.literal("high")]).optional()
4754
+ var ChatCompletionContentPartTextWithTitle = z6.object({
4755
+ text: z6.string().default(""),
4756
+ type: z6.literal("text"),
4757
+ cache_control: z6.object({ type: z6.literal("ephemeral") }).optional()
4758
+ });
4759
+ var ChatCompletionContentPartImageWithTitle = z6.object({
4760
+ image_url: z6.object({
4761
+ url: z6.string(),
4762
+ detail: z6.union([z6.literal("auto"), z6.literal("low"), z6.literal("high")]).optional()
4690
4763
  }),
4691
- type: z5.literal("image_url")
4764
+ type: z6.literal("image_url")
4692
4765
  });
4693
- var ChatCompletionContentPart = z5.union([
4766
+ var ChatCompletionContentPart = z6.union([
4694
4767
  ChatCompletionContentPartTextWithTitle,
4695
4768
  ChatCompletionContentPartImageWithTitle
4696
4769
  ]);
4697
- var ChatCompletionContentPartText = z5.object({
4698
- text: z5.string().default(""),
4699
- type: z5.literal("text"),
4700
- cache_control: z5.object({ type: z5.literal("ephemeral") }).optional()
4701
- });
4702
- var ChatCompletionMessageToolCall = z5.object({
4703
- id: z5.string(),
4704
- function: z5.object({ arguments: z5.string(), name: z5.string() }),
4705
- type: z5.literal("function")
4706
- });
4707
- var ChatCompletionMessageReasoning = z5.object({ id: z5.string(), content: z5.string() }).partial();
4708
- var ChatCompletionMessageParam = z5.union([
4709
- z5.object({
4710
- content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
4711
- role: z5.literal("system"),
4712
- name: z5.string().optional()
4770
+ var ChatCompletionContentPartText = z6.object({
4771
+ text: z6.string().default(""),
4772
+ type: z6.literal("text"),
4773
+ cache_control: z6.object({ type: z6.literal("ephemeral") }).optional()
4774
+ });
4775
+ var ChatCompletionMessageToolCall = z6.object({
4776
+ id: z6.string(),
4777
+ function: z6.object({ arguments: z6.string(), name: z6.string() }),
4778
+ type: z6.literal("function")
4779
+ });
4780
+ var ChatCompletionMessageReasoning = z6.object({ id: z6.string(), content: z6.string() }).partial();
4781
+ var ChatCompletionMessageParam = z6.union([
4782
+ z6.object({
4783
+ content: z6.union([z6.string(), z6.array(ChatCompletionContentPartText)]),
4784
+ role: z6.literal("system"),
4785
+ name: z6.string().optional()
4713
4786
  }),
4714
- z5.object({
4715
- content: z5.union([z5.string(), z5.array(ChatCompletionContentPart)]),
4716
- role: z5.literal("user"),
4717
- name: z5.string().optional()
4787
+ z6.object({
4788
+ content: z6.union([z6.string(), z6.array(ChatCompletionContentPart)]),
4789
+ role: z6.literal("user"),
4790
+ name: z6.string().optional()
4718
4791
  }),
4719
- z5.object({
4720
- role: z5.literal("assistant"),
4721
- content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText), z5.null()]).optional(),
4722
- function_call: z5.object({ arguments: z5.string(), name: z5.string() }).optional(),
4723
- name: z5.string().optional(),
4724
- tool_calls: z5.array(ChatCompletionMessageToolCall).optional(),
4725
- reasoning: z5.array(ChatCompletionMessageReasoning).optional()
4792
+ z6.object({
4793
+ role: z6.literal("assistant"),
4794
+ content: z6.union([z6.string(), z6.array(ChatCompletionContentPartText), z6.null()]).optional(),
4795
+ function_call: z6.object({ arguments: z6.string(), name: z6.string() }).optional(),
4796
+ name: z6.string().optional(),
4797
+ tool_calls: z6.array(ChatCompletionMessageToolCall).optional(),
4798
+ reasoning: z6.array(ChatCompletionMessageReasoning).optional()
4726
4799
  }),
4727
- z5.object({
4728
- content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
4729
- role: z5.literal("tool"),
4730
- tool_call_id: z5.string().default("")
4800
+ z6.object({
4801
+ content: z6.union([z6.string(), z6.array(ChatCompletionContentPartText)]),
4802
+ role: z6.literal("tool"),
4803
+ tool_call_id: z6.string().default("")
4731
4804
  }),
4732
- z5.object({
4733
- content: z5.union([z5.string(), z5.null()]),
4734
- name: z5.string(),
4735
- role: z5.literal("function")
4805
+ z6.object({
4806
+ content: z6.union([z6.string(), z6.null()]),
4807
+ name: z6.string(),
4808
+ role: z6.literal("function")
4736
4809
  }),
4737
- z5.object({
4738
- content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
4739
- role: z5.literal("developer"),
4740
- name: z5.string().optional()
4810
+ z6.object({
4811
+ content: z6.union([z6.string(), z6.array(ChatCompletionContentPartText)]),
4812
+ role: z6.literal("developer"),
4813
+ name: z6.string().optional()
4741
4814
  }),
4742
- z5.object({
4743
- role: z5.literal("model"),
4744
- content: z5.union([z5.string(), z5.null()]).optional()
4815
+ z6.object({
4816
+ role: z6.literal("model"),
4817
+ content: z6.union([z6.string(), z6.null()]).optional()
4745
4818
  })
4746
4819
  ]);
4747
- var ChatCompletionOpenAIMessageParam = z5.union([
4748
- z5.object({
4749
- content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
4750
- role: z5.literal("system"),
4751
- name: z5.string().optional()
4820
+ var ChatCompletionOpenAIMessageParam = z6.union([
4821
+ z6.object({
4822
+ content: z6.union([z6.string(), z6.array(ChatCompletionContentPartText)]),
4823
+ role: z6.literal("system"),
4824
+ name: z6.string().optional()
4752
4825
  }),
4753
- z5.object({
4754
- content: z5.union([z5.string(), z5.array(ChatCompletionContentPart)]),
4755
- role: z5.literal("user"),
4756
- name: z5.string().optional()
4826
+ z6.object({
4827
+ content: z6.union([z6.string(), z6.array(ChatCompletionContentPart)]),
4828
+ role: z6.literal("user"),
4829
+ name: z6.string().optional()
4757
4830
  }),
4758
- z5.object({
4759
- role: z5.literal("assistant"),
4760
- content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText), z5.null()]).optional(),
4761
- function_call: z5.object({ arguments: z5.string(), name: z5.string() }).optional(),
4762
- name: z5.string().optional(),
4763
- tool_calls: z5.array(ChatCompletionMessageToolCall).optional(),
4764
- reasoning: z5.array(ChatCompletionMessageReasoning).optional()
4831
+ z6.object({
4832
+ role: z6.literal("assistant"),
4833
+ content: z6.union([z6.string(), z6.array(ChatCompletionContentPartText), z6.null()]).optional(),
4834
+ function_call: z6.object({ arguments: z6.string(), name: z6.string() }).optional(),
4835
+ name: z6.string().optional(),
4836
+ tool_calls: z6.array(ChatCompletionMessageToolCall).optional(),
4837
+ reasoning: z6.array(ChatCompletionMessageReasoning).optional()
4765
4838
  }),
4766
- z5.object({
4767
- content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
4768
- role: z5.literal("tool"),
4769
- tool_call_id: z5.string().default("")
4839
+ z6.object({
4840
+ content: z6.union([z6.string(), z6.array(ChatCompletionContentPartText)]),
4841
+ role: z6.literal("tool"),
4842
+ tool_call_id: z6.string().default("")
4770
4843
  }),
4771
- z5.object({
4772
- content: z5.union([z5.string(), z5.null()]),
4773
- name: z5.string(),
4774
- role: z5.literal("function")
4844
+ z6.object({
4845
+ content: z6.union([z6.string(), z6.null()]),
4846
+ name: z6.string(),
4847
+ role: z6.literal("function")
4775
4848
  }),
4776
- z5.object({
4777
- content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
4778
- role: z5.literal("developer"),
4779
- name: z5.string().optional()
4849
+ z6.object({
4850
+ content: z6.union([z6.string(), z6.array(ChatCompletionContentPartText)]),
4851
+ role: z6.literal("developer"),
4852
+ name: z6.string().optional()
4780
4853
  })
4781
4854
  ]);
4782
- var ChatCompletionTool = z5.object({
4783
- function: z5.object({
4784
- name: z5.string(),
4785
- description: z5.string().optional(),
4786
- parameters: z5.object({}).partial().passthrough().optional()
4855
+ var ChatCompletionTool = z6.object({
4856
+ function: z6.object({
4857
+ name: z6.string(),
4858
+ description: z6.string().optional(),
4859
+ parameters: z6.object({}).partial().passthrough().optional()
4787
4860
  }),
4788
- type: z5.literal("function")
4861
+ type: z6.literal("function")
4789
4862
  });
4790
- var CodeBundle = z5.object({
4791
- runtime_context: z5.object({
4792
- runtime: z5.enum(["node", "python"]),
4793
- version: z5.string()
4863
+ var CodeBundle = z6.object({
4864
+ runtime_context: z6.object({
4865
+ runtime: z6.enum(["node", "python"]),
4866
+ version: z6.string()
4794
4867
  }),
4795
- location: z5.union([
4796
- z5.object({
4797
- type: z5.literal("experiment"),
4798
- eval_name: z5.string(),
4799
- position: z5.union([
4800
- z5.object({ type: z5.literal("task") }),
4801
- z5.object({ type: z5.literal("scorer"), index: z5.number().int().gte(0) })
4868
+ location: z6.union([
4869
+ z6.object({
4870
+ type: z6.literal("experiment"),
4871
+ eval_name: z6.string(),
4872
+ position: z6.union([
4873
+ z6.object({ type: z6.literal("task") }),
4874
+ z6.object({ type: z6.literal("scorer"), index: z6.number().int().gte(0) })
4802
4875
  ])
4803
4876
  }),
4804
- z5.object({ type: z5.literal("function"), index: z5.number().int().gte(0) })
4877
+ z6.object({ type: z6.literal("function"), index: z6.number().int().gte(0) })
4805
4878
  ]),
4806
- bundle_id: z5.string(),
4807
- preview: z5.union([z5.string(), z5.null()]).optional()
4808
- });
4809
- var Dataset = z5.object({
4810
- id: z5.string().uuid(),
4811
- project_id: z5.string().uuid(),
4812
- name: z5.string(),
4813
- description: z5.union([z5.string(), z5.null()]).optional(),
4814
- created: z5.union([z5.string(), z5.null()]).optional(),
4815
- deleted_at: z5.union([z5.string(), z5.null()]).optional(),
4816
- user_id: z5.union([z5.string(), z5.null()]).optional(),
4817
- metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
4818
- });
4819
- var ObjectReferenceNullish = z5.union([
4820
- z5.object({
4821
- object_type: z5.enum([
4879
+ bundle_id: z6.string(),
4880
+ preview: z6.union([z6.string(), z6.null()]).optional()
4881
+ });
4882
+ var Dataset = z6.object({
4883
+ id: z6.string().uuid(),
4884
+ project_id: z6.string().uuid(),
4885
+ name: z6.string(),
4886
+ description: z6.union([z6.string(), z6.null()]).optional(),
4887
+ created: z6.union([z6.string(), z6.null()]).optional(),
4888
+ deleted_at: z6.union([z6.string(), z6.null()]).optional(),
4889
+ user_id: z6.union([z6.string(), z6.null()]).optional(),
4890
+ metadata: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional()
4891
+ });
4892
+ var ObjectReferenceNullish = z6.union([
4893
+ z6.object({
4894
+ object_type: z6.enum([
4822
4895
  "project_logs",
4823
4896
  "experiment",
4824
4897
  "dataset",
@@ -4826,399 +4899,399 @@ var ObjectReferenceNullish = z5.union([
4826
4899
  "function",
4827
4900
  "prompt_session"
4828
4901
  ]),
4829
- object_id: z5.string().uuid(),
4830
- id: z5.string(),
4831
- _xact_id: z5.union([z5.string(), z5.null()]).optional(),
4832
- created: z5.union([z5.string(), z5.null()]).optional()
4902
+ object_id: z6.string().uuid(),
4903
+ id: z6.string(),
4904
+ _xact_id: z6.union([z6.string(), z6.null()]).optional(),
4905
+ created: z6.union([z6.string(), z6.null()]).optional()
4833
4906
  }),
4834
- z5.null()
4907
+ z6.null()
4835
4908
  ]);
4836
- var DatasetEvent = z5.object({
4837
- id: z5.string(),
4838
- _xact_id: z5.string(),
4839
- created: z5.string().datetime({ offset: true }),
4840
- _pagination_key: z5.union([z5.string(), z5.null()]).optional(),
4841
- project_id: z5.string().uuid(),
4842
- dataset_id: z5.string().uuid(),
4843
- input: z5.unknown().optional(),
4844
- expected: z5.unknown().optional(),
4845
- metadata: z5.union([
4846
- z5.object({ model: z5.union([z5.string(), z5.null()]) }).partial().passthrough(),
4847
- z5.null()
4909
+ var DatasetEvent = z6.object({
4910
+ id: z6.string(),
4911
+ _xact_id: z6.string(),
4912
+ created: z6.string().datetime({ offset: true }),
4913
+ _pagination_key: z6.union([z6.string(), z6.null()]).optional(),
4914
+ project_id: z6.string().uuid(),
4915
+ dataset_id: z6.string().uuid(),
4916
+ input: z6.unknown().optional(),
4917
+ expected: z6.unknown().optional(),
4918
+ metadata: z6.union([
4919
+ z6.object({ model: z6.union([z6.string(), z6.null()]) }).partial().passthrough(),
4920
+ z6.null()
4848
4921
  ]).optional(),
4849
- tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
4850
- span_id: z5.string(),
4851
- root_span_id: z5.string(),
4852
- is_root: z5.union([z5.boolean(), z5.null()]).optional(),
4922
+ tags: z6.union([z6.array(z6.string()), z6.null()]).optional(),
4923
+ span_id: z6.string(),
4924
+ root_span_id: z6.string(),
4925
+ is_root: z6.union([z6.boolean(), z6.null()]).optional(),
4853
4926
  origin: ObjectReferenceNullish.optional()
4854
4927
  });
4855
- var EnvVar = z5.object({
4856
- id: z5.string().uuid(),
4857
- object_type: z5.enum(["organization", "project", "function"]),
4858
- object_id: z5.string().uuid(),
4859
- name: z5.string(),
4860
- created: z5.union([z5.string(), z5.null()]).optional(),
4861
- used: z5.union([z5.string(), z5.null()]).optional()
4862
- });
4863
- var RepoInfo = z5.union([
4864
- z5.object({
4865
- commit: z5.union([z5.string(), z5.null()]),
4866
- branch: z5.union([z5.string(), z5.null()]),
4867
- tag: z5.union([z5.string(), z5.null()]),
4868
- dirty: z5.union([z5.boolean(), z5.null()]),
4869
- author_name: z5.union([z5.string(), z5.null()]),
4870
- author_email: z5.union([z5.string(), z5.null()]),
4871
- commit_message: z5.union([z5.string(), z5.null()]),
4872
- commit_time: z5.union([z5.string(), z5.null()]),
4873
- git_diff: z5.union([z5.string(), z5.null()])
4928
+ var EnvVar = z6.object({
4929
+ id: z6.string().uuid(),
4930
+ object_type: z6.enum(["organization", "project", "function"]),
4931
+ object_id: z6.string().uuid(),
4932
+ name: z6.string(),
4933
+ created: z6.union([z6.string(), z6.null()]).optional(),
4934
+ used: z6.union([z6.string(), z6.null()]).optional()
4935
+ });
4936
+ var RepoInfo = z6.union([
4937
+ z6.object({
4938
+ commit: z6.union([z6.string(), z6.null()]),
4939
+ branch: z6.union([z6.string(), z6.null()]),
4940
+ tag: z6.union([z6.string(), z6.null()]),
4941
+ dirty: z6.union([z6.boolean(), z6.null()]),
4942
+ author_name: z6.union([z6.string(), z6.null()]),
4943
+ author_email: z6.union([z6.string(), z6.null()]),
4944
+ commit_message: z6.union([z6.string(), z6.null()]),
4945
+ commit_time: z6.union([z6.string(), z6.null()]),
4946
+ git_diff: z6.union([z6.string(), z6.null()])
4874
4947
  }).partial(),
4875
- z5.null()
4948
+ z6.null()
4876
4949
  ]);
4877
- var Experiment = z5.object({
4878
- id: z5.string().uuid(),
4879
- project_id: z5.string().uuid(),
4880
- name: z5.string(),
4881
- description: z5.union([z5.string(), z5.null()]).optional(),
4882
- created: z5.union([z5.string(), z5.null()]).optional(),
4950
+ var Experiment = z6.object({
4951
+ id: z6.string().uuid(),
4952
+ project_id: z6.string().uuid(),
4953
+ name: z6.string(),
4954
+ description: z6.union([z6.string(), z6.null()]).optional(),
4955
+ created: z6.union([z6.string(), z6.null()]).optional(),
4883
4956
  repo_info: RepoInfo.optional(),
4884
- commit: z5.union([z5.string(), z5.null()]).optional(),
4885
- base_exp_id: z5.union([z5.string(), z5.null()]).optional(),
4886
- deleted_at: z5.union([z5.string(), z5.null()]).optional(),
4887
- dataset_id: z5.union([z5.string(), z5.null()]).optional(),
4888
- dataset_version: z5.union([z5.string(), z5.null()]).optional(),
4889
- public: z5.boolean(),
4890
- user_id: z5.union([z5.string(), z5.null()]).optional(),
4891
- metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
4892
- tags: z5.union([z5.array(z5.string()), z5.null()]).optional()
4893
- });
4894
- var SpanType = z5.union([
4895
- z5.enum(["llm", "score", "function", "eval", "task", "tool"]),
4896
- z5.null()
4957
+ commit: z6.union([z6.string(), z6.null()]).optional(),
4958
+ base_exp_id: z6.union([z6.string(), z6.null()]).optional(),
4959
+ deleted_at: z6.union([z6.string(), z6.null()]).optional(),
4960
+ dataset_id: z6.union([z6.string(), z6.null()]).optional(),
4961
+ dataset_version: z6.union([z6.string(), z6.null()]).optional(),
4962
+ public: z6.boolean(),
4963
+ user_id: z6.union([z6.string(), z6.null()]).optional(),
4964
+ metadata: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional(),
4965
+ tags: z6.union([z6.array(z6.string()), z6.null()]).optional()
4966
+ });
4967
+ var SpanType = z6.union([
4968
+ z6.enum(["llm", "score", "function", "eval", "task", "tool"]),
4969
+ z6.null()
4897
4970
  ]);
4898
- var SpanAttributes = z5.union([
4899
- z5.object({ name: z5.union([z5.string(), z5.null()]), type: SpanType }).partial().passthrough(),
4900
- z5.null()
4971
+ var SpanAttributes = z6.union([
4972
+ z6.object({ name: z6.union([z6.string(), z6.null()]), type: SpanType }).partial().passthrough(),
4973
+ z6.null()
4901
4974
  ]);
4902
- var ExperimentEvent = z5.object({
4903
- id: z5.string(),
4904
- _xact_id: z5.string(),
4905
- created: z5.string().datetime({ offset: true }),
4906
- _pagination_key: z5.union([z5.string(), z5.null()]).optional(),
4907
- project_id: z5.string().uuid(),
4908
- experiment_id: z5.string().uuid(),
4909
- input: z5.unknown().optional(),
4910
- output: z5.unknown().optional(),
4911
- expected: z5.unknown().optional(),
4912
- error: z5.unknown().optional(),
4913
- scores: z5.union([z5.record(z5.union([z5.number(), z5.null()])), z5.null()]).optional(),
4914
- metadata: z5.union([
4915
- z5.object({ model: z5.union([z5.string(), z5.null()]) }).partial().passthrough(),
4916
- z5.null()
4975
+ var ExperimentEvent = z6.object({
4976
+ id: z6.string(),
4977
+ _xact_id: z6.string(),
4978
+ created: z6.string().datetime({ offset: true }),
4979
+ _pagination_key: z6.union([z6.string(), z6.null()]).optional(),
4980
+ project_id: z6.string().uuid(),
4981
+ experiment_id: z6.string().uuid(),
4982
+ input: z6.unknown().optional(),
4983
+ output: z6.unknown().optional(),
4984
+ expected: z6.unknown().optional(),
4985
+ error: z6.unknown().optional(),
4986
+ scores: z6.union([z6.record(z6.union([z6.number(), z6.null()])), z6.null()]).optional(),
4987
+ metadata: z6.union([
4988
+ z6.object({ model: z6.union([z6.string(), z6.null()]) }).partial().passthrough(),
4989
+ z6.null()
4917
4990
  ]).optional(),
4918
- tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
4919
- metrics: z5.union([z5.record(z5.number()), z5.null()]).optional(),
4920
- context: z5.union([
4921
- z5.object({
4922
- caller_functionname: z5.union([z5.string(), z5.null()]),
4923
- caller_filename: z5.union([z5.string(), z5.null()]),
4924
- caller_lineno: z5.union([z5.number(), z5.null()])
4991
+ tags: z6.union([z6.array(z6.string()), z6.null()]).optional(),
4992
+ metrics: z6.union([z6.record(z6.number()), z6.null()]).optional(),
4993
+ context: z6.union([
4994
+ z6.object({
4995
+ caller_functionname: z6.union([z6.string(), z6.null()]),
4996
+ caller_filename: z6.union([z6.string(), z6.null()]),
4997
+ caller_lineno: z6.union([z6.number(), z6.null()])
4925
4998
  }).partial().passthrough(),
4926
- z5.null()
4999
+ z6.null()
4927
5000
  ]).optional(),
4928
- span_id: z5.string(),
4929
- span_parents: z5.union([z5.array(z5.string()), z5.null()]).optional(),
4930
- root_span_id: z5.string(),
5001
+ span_id: z6.string(),
5002
+ span_parents: z6.union([z6.array(z6.string()), z6.null()]).optional(),
5003
+ root_span_id: z6.string(),
4931
5004
  span_attributes: SpanAttributes.optional(),
4932
- is_root: z5.union([z5.boolean(), z5.null()]).optional(),
5005
+ is_root: z6.union([z6.boolean(), z6.null()]).optional(),
4933
5006
  origin: ObjectReferenceNullish.optional()
4934
5007
  });
4935
- var ExtendedSavedFunctionId = z5.union([
4936
- z5.object({ type: z5.literal("function"), id: z5.string() }),
4937
- z5.object({ type: z5.literal("global"), name: z5.string() }),
4938
- z5.object({
4939
- type: z5.literal("slug"),
4940
- project_id: z5.string(),
4941
- slug: z5.string()
5008
+ var ExtendedSavedFunctionId = z6.union([
5009
+ z6.object({ type: z6.literal("function"), id: z6.string() }),
5010
+ z6.object({ type: z6.literal("global"), name: z6.string() }),
5011
+ z6.object({
5012
+ type: z6.literal("slug"),
5013
+ project_id: z6.string(),
5014
+ slug: z6.string()
4942
5015
  })
4943
5016
  ]);
4944
- var PromptBlockDataNullish = z5.union([
4945
- z5.object({ type: z5.literal("completion"), content: z5.string() }),
4946
- z5.object({
4947
- type: z5.literal("chat"),
4948
- messages: z5.array(ChatCompletionMessageParam),
4949
- tools: z5.string().optional()
5017
+ var PromptBlockDataNullish = z6.union([
5018
+ z6.object({ type: z6.literal("completion"), content: z6.string() }),
5019
+ z6.object({
5020
+ type: z6.literal("chat"),
5021
+ messages: z6.array(ChatCompletionMessageParam),
5022
+ tools: z6.string().optional()
4950
5023
  }),
4951
- z5.null()
5024
+ z6.null()
4952
5025
  ]);
4953
- var ModelParams = z5.union([
4954
- z5.object({
4955
- use_cache: z5.boolean(),
4956
- temperature: z5.number(),
4957
- top_p: z5.number(),
4958
- max_tokens: z5.number(),
4959
- max_completion_tokens: z5.number(),
4960
- frequency_penalty: z5.number(),
4961
- presence_penalty: z5.number(),
5026
+ var ModelParams = z6.union([
5027
+ z6.object({
5028
+ use_cache: z6.boolean(),
5029
+ temperature: z6.number(),
5030
+ top_p: z6.number(),
5031
+ max_tokens: z6.number(),
5032
+ max_completion_tokens: z6.number(),
5033
+ frequency_penalty: z6.number(),
5034
+ presence_penalty: z6.number(),
4962
5035
  response_format: ResponseFormatNullish,
4963
- tool_choice: z5.union([
4964
- z5.literal("auto"),
4965
- z5.literal("none"),
4966
- z5.literal("required"),
4967
- z5.object({
4968
- type: z5.literal("function"),
4969
- function: z5.object({ name: z5.string() })
5036
+ tool_choice: z6.union([
5037
+ z6.literal("auto"),
5038
+ z6.literal("none"),
5039
+ z6.literal("required"),
5040
+ z6.object({
5041
+ type: z6.literal("function"),
5042
+ function: z6.object({ name: z6.string() })
4970
5043
  })
4971
5044
  ]),
4972
- function_call: z5.union([
4973
- z5.literal("auto"),
4974
- z5.literal("none"),
4975
- z5.object({ name: z5.string() })
5045
+ function_call: z6.union([
5046
+ z6.literal("auto"),
5047
+ z6.literal("none"),
5048
+ z6.object({ name: z6.string() })
4976
5049
  ]),
4977
- n: z5.number(),
4978
- stop: z5.array(z5.string()),
4979
- reasoning_effort: z5.enum(["minimal", "low", "medium", "high"]),
4980
- verbosity: z5.enum(["low", "medium", "high"])
5050
+ n: z6.number(),
5051
+ stop: z6.array(z6.string()),
5052
+ reasoning_effort: z6.enum(["minimal", "low", "medium", "high"]),
5053
+ verbosity: z6.enum(["low", "medium", "high"])
4981
5054
  }).partial().passthrough(),
4982
- z5.object({
4983
- use_cache: z5.boolean().optional(),
4984
- max_tokens: z5.number(),
4985
- temperature: z5.number(),
4986
- top_p: z5.number().optional(),
4987
- top_k: z5.number().optional(),
4988
- stop_sequences: z5.array(z5.string()).optional(),
4989
- max_tokens_to_sample: z5.number().optional()
5055
+ z6.object({
5056
+ use_cache: z6.boolean().optional(),
5057
+ max_tokens: z6.number(),
5058
+ temperature: z6.number(),
5059
+ top_p: z6.number().optional(),
5060
+ top_k: z6.number().optional(),
5061
+ stop_sequences: z6.array(z6.string()).optional(),
5062
+ max_tokens_to_sample: z6.number().optional()
4990
5063
  }).passthrough(),
4991
- z5.object({
4992
- use_cache: z5.boolean(),
4993
- temperature: z5.number(),
4994
- maxOutputTokens: z5.number(),
4995
- topP: z5.number(),
4996
- topK: z5.number()
5064
+ z6.object({
5065
+ use_cache: z6.boolean(),
5066
+ temperature: z6.number(),
5067
+ maxOutputTokens: z6.number(),
5068
+ topP: z6.number(),
5069
+ topK: z6.number()
4997
5070
  }).partial().passthrough(),
4998
- z5.object({
4999
- use_cache: z5.boolean(),
5000
- temperature: z5.number(),
5001
- topK: z5.number()
5071
+ z6.object({
5072
+ use_cache: z6.boolean(),
5073
+ temperature: z6.number(),
5074
+ topK: z6.number()
5002
5075
  }).partial().passthrough(),
5003
- z5.object({ use_cache: z5.boolean() }).partial().passthrough()
5076
+ z6.object({ use_cache: z6.boolean() }).partial().passthrough()
5004
5077
  ]);
5005
- var PromptOptionsNullish = z5.union([
5006
- z5.object({ model: z5.string(), params: ModelParams, position: z5.string() }).partial(),
5007
- z5.null()
5078
+ var PromptOptionsNullish = z6.union([
5079
+ z6.object({ model: z6.string(), params: ModelParams, position: z6.string() }).partial(),
5080
+ z6.null()
5008
5081
  ]);
5009
- var PromptParserNullish = z5.union([
5010
- z5.object({
5011
- type: z5.literal("llm_classifier"),
5012
- use_cot: z5.boolean(),
5013
- choice_scores: z5.record(z5.number().gte(0).lte(1))
5082
+ var PromptParserNullish = z6.union([
5083
+ z6.object({
5084
+ type: z6.literal("llm_classifier"),
5085
+ use_cot: z6.boolean(),
5086
+ choice_scores: z6.record(z6.number().gte(0).lte(1))
5014
5087
  }),
5015
- z5.null()
5088
+ z6.null()
5016
5089
  ]);
5017
- var SavedFunctionId = z5.union([
5018
- z5.object({ type: z5.literal("function"), id: z5.string() }),
5019
- z5.object({ type: z5.literal("global"), name: z5.string() })
5090
+ var SavedFunctionId = z6.union([
5091
+ z6.object({ type: z6.literal("function"), id: z6.string() }),
5092
+ z6.object({ type: z6.literal("global"), name: z6.string() })
5020
5093
  ]);
5021
- var PromptDataNullish = z5.union([
5022
- z5.object({
5094
+ var PromptDataNullish = z6.union([
5095
+ z6.object({
5023
5096
  prompt: PromptBlockDataNullish,
5024
5097
  options: PromptOptionsNullish,
5025
5098
  parser: PromptParserNullish,
5026
- tool_functions: z5.union([z5.array(SavedFunctionId), z5.null()]),
5027
- origin: z5.union([
5028
- z5.object({
5029
- prompt_id: z5.string(),
5030
- project_id: z5.string(),
5031
- prompt_version: z5.string()
5099
+ tool_functions: z6.union([z6.array(SavedFunctionId), z6.null()]),
5100
+ origin: z6.union([
5101
+ z6.object({
5102
+ prompt_id: z6.string(),
5103
+ project_id: z6.string(),
5104
+ prompt_version: z6.string()
5032
5105
  }).partial(),
5033
- z5.null()
5106
+ z6.null()
5034
5107
  ])
5035
5108
  }).partial(),
5036
- z5.null()
5109
+ z6.null()
5037
5110
  ]);
5038
- var FunctionTypeEnumNullish = z5.union([
5039
- z5.enum(["llm", "scorer", "task", "tool"]),
5040
- z5.null()
5111
+ var FunctionTypeEnumNullish = z6.union([
5112
+ z6.enum(["llm", "scorer", "task", "tool"]),
5113
+ z6.null()
5041
5114
  ]);
5042
- var FunctionIdRef = z5.object({}).partial().passthrough();
5043
- var PromptBlockData = z5.union([
5044
- z5.object({ type: z5.literal("completion"), content: z5.string() }),
5045
- z5.object({
5046
- type: z5.literal("chat"),
5047
- messages: z5.array(ChatCompletionMessageParam),
5048
- tools: z5.string().optional()
5115
+ var FunctionIdRef = z6.object({}).partial().passthrough();
5116
+ var PromptBlockData = z6.union([
5117
+ z6.object({ type: z6.literal("completion"), content: z6.string() }),
5118
+ z6.object({
5119
+ type: z6.literal("chat"),
5120
+ messages: z6.array(ChatCompletionMessageParam),
5121
+ tools: z6.string().optional()
5049
5122
  })
5050
5123
  ]);
5051
- var GraphNode = z5.union([
5052
- z5.object({
5053
- description: z5.union([z5.string(), z5.null()]).optional(),
5054
- position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
5055
- type: z5.literal("function"),
5124
+ var GraphNode = z6.union([
5125
+ z6.object({
5126
+ description: z6.union([z6.string(), z6.null()]).optional(),
5127
+ position: z6.union([z6.object({ x: z6.number(), y: z6.number() }), z6.null()]).optional(),
5128
+ type: z6.literal("function"),
5056
5129
  function: FunctionIdRef
5057
5130
  }),
5058
- z5.object({
5059
- description: z5.union([z5.string(), z5.null()]).optional(),
5060
- position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
5061
- type: z5.literal("input")
5131
+ z6.object({
5132
+ description: z6.union([z6.string(), z6.null()]).optional(),
5133
+ position: z6.union([z6.object({ x: z6.number(), y: z6.number() }), z6.null()]).optional(),
5134
+ type: z6.literal("input")
5062
5135
  }),
5063
- z5.object({
5064
- description: z5.union([z5.string(), z5.null()]).optional(),
5065
- position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
5066
- type: z5.literal("output")
5136
+ z6.object({
5137
+ description: z6.union([z6.string(), z6.null()]).optional(),
5138
+ position: z6.union([z6.object({ x: z6.number(), y: z6.number() }), z6.null()]).optional(),
5139
+ type: z6.literal("output")
5067
5140
  }),
5068
- z5.object({
5069
- description: z5.union([z5.string(), z5.null()]).optional(),
5070
- position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
5071
- type: z5.literal("literal"),
5072
- value: z5.unknown().optional()
5141
+ z6.object({
5142
+ description: z6.union([z6.string(), z6.null()]).optional(),
5143
+ position: z6.union([z6.object({ x: z6.number(), y: z6.number() }), z6.null()]).optional(),
5144
+ type: z6.literal("literal"),
5145
+ value: z6.unknown().optional()
5073
5146
  }),
5074
- z5.object({
5075
- description: z5.union([z5.string(), z5.null()]).optional(),
5076
- position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
5077
- type: z5.literal("btql"),
5078
- expr: z5.string()
5147
+ z6.object({
5148
+ description: z6.union([z6.string(), z6.null()]).optional(),
5149
+ position: z6.union([z6.object({ x: z6.number(), y: z6.number() }), z6.null()]).optional(),
5150
+ type: z6.literal("btql"),
5151
+ expr: z6.string()
5079
5152
  }),
5080
- z5.object({
5081
- description: z5.union([z5.string(), z5.null()]).optional(),
5082
- position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
5083
- type: z5.literal("gate"),
5084
- condition: z5.union([z5.string(), z5.null()]).optional()
5153
+ z6.object({
5154
+ description: z6.union([z6.string(), z6.null()]).optional(),
5155
+ position: z6.union([z6.object({ x: z6.number(), y: z6.number() }), z6.null()]).optional(),
5156
+ type: z6.literal("gate"),
5157
+ condition: z6.union([z6.string(), z6.null()]).optional()
5085
5158
  }),
5086
- z5.object({
5087
- description: z5.union([z5.string(), z5.null()]).optional(),
5088
- position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
5089
- type: z5.literal("aggregator")
5159
+ z6.object({
5160
+ description: z6.union([z6.string(), z6.null()]).optional(),
5161
+ position: z6.union([z6.object({ x: z6.number(), y: z6.number() }), z6.null()]).optional(),
5162
+ type: z6.literal("aggregator")
5090
5163
  }),
5091
- z5.object({
5092
- description: z5.union([z5.string(), z5.null()]).optional(),
5093
- position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
5094
- type: z5.literal("prompt_template"),
5164
+ z6.object({
5165
+ description: z6.union([z6.string(), z6.null()]).optional(),
5166
+ position: z6.union([z6.object({ x: z6.number(), y: z6.number() }), z6.null()]).optional(),
5167
+ type: z6.literal("prompt_template"),
5095
5168
  prompt: PromptBlockData
5096
5169
  })
5097
5170
  ]);
5098
- var GraphEdge = z5.object({
5099
- source: z5.object({ node: z5.string().max(1024), variable: z5.string() }),
5100
- target: z5.object({ node: z5.string().max(1024), variable: z5.string() }),
5101
- purpose: z5.enum(["control", "data", "messages"])
5102
- });
5103
- var GraphData = z5.object({
5104
- type: z5.literal("graph"),
5105
- nodes: z5.record(GraphNode),
5106
- edges: z5.record(GraphEdge)
5107
- });
5108
- var FunctionData = z5.union([
5109
- z5.object({ type: z5.literal("prompt") }),
5110
- z5.object({
5111
- type: z5.literal("code"),
5112
- data: z5.union([
5113
- z5.object({ type: z5.literal("bundle") }).and(CodeBundle),
5114
- z5.object({
5115
- type: z5.literal("inline"),
5116
- runtime_context: z5.object({
5117
- runtime: z5.enum(["node", "python"]),
5118
- version: z5.string()
5171
+ var GraphEdge = z6.object({
5172
+ source: z6.object({ node: z6.string().max(1024), variable: z6.string() }),
5173
+ target: z6.object({ node: z6.string().max(1024), variable: z6.string() }),
5174
+ purpose: z6.enum(["control", "data", "messages"])
5175
+ });
5176
+ var GraphData = z6.object({
5177
+ type: z6.literal("graph"),
5178
+ nodes: z6.record(GraphNode),
5179
+ edges: z6.record(GraphEdge)
5180
+ });
5181
+ var FunctionData = z6.union([
5182
+ z6.object({ type: z6.literal("prompt") }),
5183
+ z6.object({
5184
+ type: z6.literal("code"),
5185
+ data: z6.union([
5186
+ z6.object({ type: z6.literal("bundle") }).and(CodeBundle),
5187
+ z6.object({
5188
+ type: z6.literal("inline"),
5189
+ runtime_context: z6.object({
5190
+ runtime: z6.enum(["node", "python"]),
5191
+ version: z6.string()
5119
5192
  }),
5120
- code: z5.string()
5193
+ code: z6.string()
5121
5194
  })
5122
5195
  ])
5123
5196
  }),
5124
5197
  GraphData,
5125
- z5.object({
5126
- type: z5.literal("remote_eval"),
5127
- endpoint: z5.string(),
5128
- eval_name: z5.string(),
5129
- parameters: z5.object({}).partial().passthrough()
5198
+ z6.object({
5199
+ type: z6.literal("remote_eval"),
5200
+ endpoint: z6.string(),
5201
+ eval_name: z6.string(),
5202
+ parameters: z6.object({}).partial().passthrough()
5130
5203
  }),
5131
- z5.object({ type: z5.literal("global"), name: z5.string() })
5204
+ z6.object({ type: z6.literal("global"), name: z6.string() })
5132
5205
  ]);
5133
- var Function2 = z5.object({
5134
- id: z5.string().uuid(),
5135
- _xact_id: z5.string(),
5136
- project_id: z5.string().uuid(),
5137
- log_id: z5.literal("p"),
5138
- org_id: z5.string().uuid(),
5139
- name: z5.string(),
5140
- slug: z5.string(),
5141
- description: z5.union([z5.string(), z5.null()]).optional(),
5142
- created: z5.union([z5.string(), z5.null()]).optional(),
5206
+ var Function2 = z6.object({
5207
+ id: z6.string().uuid(),
5208
+ _xact_id: z6.string(),
5209
+ project_id: z6.string().uuid(),
5210
+ log_id: z6.literal("p"),
5211
+ org_id: z6.string().uuid(),
5212
+ name: z6.string(),
5213
+ slug: z6.string(),
5214
+ description: z6.union([z6.string(), z6.null()]).optional(),
5215
+ created: z6.union([z6.string(), z6.null()]).optional(),
5143
5216
  prompt_data: PromptDataNullish.optional(),
5144
- tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
5145
- metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
5217
+ tags: z6.union([z6.array(z6.string()), z6.null()]).optional(),
5218
+ metadata: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional(),
5146
5219
  function_type: FunctionTypeEnumNullish.optional(),
5147
5220
  function_data: FunctionData,
5148
- origin: z5.union([
5149
- z5.object({
5150
- object_type: AclObjectType.and(z5.string()),
5151
- object_id: z5.string().uuid(),
5152
- internal: z5.union([z5.boolean(), z5.null()]).optional()
5221
+ origin: z6.union([
5222
+ z6.object({
5223
+ object_type: AclObjectType.and(z6.string()),
5224
+ object_id: z6.string().uuid(),
5225
+ internal: z6.union([z6.boolean(), z6.null()]).optional()
5153
5226
  }),
5154
- z5.null()
5227
+ z6.null()
5155
5228
  ]).optional(),
5156
- function_schema: z5.union([
5157
- z5.object({ parameters: z5.unknown(), returns: z5.unknown() }).partial(),
5158
- z5.null()
5229
+ function_schema: z6.union([
5230
+ z6.object({ parameters: z6.unknown(), returns: z6.unknown() }).partial(),
5231
+ z6.null()
5159
5232
  ]).optional()
5160
5233
  });
5161
- var FunctionFormat = z5.enum(["llm", "code", "global", "graph"]);
5162
- var PromptData = z5.object({
5234
+ var FunctionFormat = z6.enum(["llm", "code", "global", "graph"]);
5235
+ var PromptData = z6.object({
5163
5236
  prompt: PromptBlockDataNullish,
5164
5237
  options: PromptOptionsNullish,
5165
5238
  parser: PromptParserNullish,
5166
- tool_functions: z5.union([z5.array(SavedFunctionId), z5.null()]),
5167
- origin: z5.union([
5168
- z5.object({
5169
- prompt_id: z5.string(),
5170
- project_id: z5.string(),
5171
- prompt_version: z5.string()
5239
+ tool_functions: z6.union([z6.array(SavedFunctionId), z6.null()]),
5240
+ origin: z6.union([
5241
+ z6.object({
5242
+ prompt_id: z6.string(),
5243
+ project_id: z6.string(),
5244
+ prompt_version: z6.string()
5172
5245
  }).partial(),
5173
- z5.null()
5246
+ z6.null()
5174
5247
  ])
5175
5248
  }).partial();
5176
- var FunctionTypeEnum = z5.enum(["llm", "scorer", "task", "tool"]);
5177
- var FunctionId = z5.union([
5178
- z5.object({ function_id: z5.string(), version: z5.string().optional() }),
5179
- z5.object({
5180
- project_name: z5.string(),
5181
- slug: z5.string(),
5182
- version: z5.string().optional()
5249
+ var FunctionTypeEnum = z6.enum(["llm", "scorer", "task", "tool"]);
5250
+ var FunctionId = z6.union([
5251
+ z6.object({ function_id: z6.string(), version: z6.string().optional() }),
5252
+ z6.object({
5253
+ project_name: z6.string(),
5254
+ slug: z6.string(),
5255
+ version: z6.string().optional()
5183
5256
  }),
5184
- z5.object({ global_function: z5.string() }),
5185
- z5.object({
5186
- prompt_session_id: z5.string(),
5187
- prompt_session_function_id: z5.string(),
5188
- version: z5.string().optional()
5257
+ z6.object({ global_function: z6.string() }),
5258
+ z6.object({
5259
+ prompt_session_id: z6.string(),
5260
+ prompt_session_function_id: z6.string(),
5261
+ version: z6.string().optional()
5189
5262
  }),
5190
- z5.object({
5191
- inline_context: z5.object({
5192
- runtime: z5.enum(["node", "python"]),
5193
- version: z5.string()
5263
+ z6.object({
5264
+ inline_context: z6.object({
5265
+ runtime: z6.enum(["node", "python"]),
5266
+ version: z6.string()
5194
5267
  }),
5195
- code: z5.string(),
5196
- name: z5.union([z5.string(), z5.null()]).optional()
5268
+ code: z6.string(),
5269
+ name: z6.union([z6.string(), z6.null()]).optional()
5197
5270
  }),
5198
- z5.object({
5271
+ z6.object({
5199
5272
  inline_prompt: PromptData.optional(),
5200
- inline_function: z5.object({}).partial().passthrough(),
5273
+ inline_function: z6.object({}).partial().passthrough(),
5201
5274
  function_type: FunctionTypeEnum.optional(),
5202
- name: z5.union([z5.string(), z5.null()]).optional()
5275
+ name: z6.union([z6.string(), z6.null()]).optional()
5203
5276
  }),
5204
- z5.object({
5277
+ z6.object({
5205
5278
  inline_prompt: PromptData,
5206
5279
  function_type: FunctionTypeEnum.optional(),
5207
- name: z5.union([z5.string(), z5.null()]).optional()
5280
+ name: z6.union([z6.string(), z6.null()]).optional()
5208
5281
  })
5209
5282
  ]);
5210
- var FunctionObjectType = z5.enum([
5283
+ var FunctionObjectType = z6.enum([
5211
5284
  "prompt",
5212
5285
  "tool",
5213
5286
  "scorer",
5214
5287
  "task",
5215
5288
  "agent"
5216
5289
  ]);
5217
- var FunctionOutputType = z5.enum(["completion", "score", "any"]);
5218
- var GitMetadataSettings = z5.object({
5219
- collect: z5.enum(["all", "none", "some"]),
5220
- fields: z5.array(
5221
- z5.enum([
5290
+ var FunctionOutputType = z6.enum(["completion", "score", "any"]);
5291
+ var GitMetadataSettings = z6.object({
5292
+ collect: z6.enum(["all", "none", "some"]),
5293
+ fields: z6.array(
5294
+ z6.enum([
5222
5295
  "commit",
5223
5296
  "branch",
5224
5297
  "tag",
@@ -5231,49 +5304,49 @@ var GitMetadataSettings = z5.object({
5231
5304
  ])
5232
5305
  ).optional()
5233
5306
  });
5234
- var Group = z5.object({
5235
- id: z5.string().uuid(),
5236
- org_id: z5.string().uuid(),
5237
- user_id: z5.union([z5.string(), z5.null()]).optional(),
5238
- created: z5.union([z5.string(), z5.null()]).optional(),
5239
- name: z5.string(),
5240
- description: z5.union([z5.string(), z5.null()]).optional(),
5241
- deleted_at: z5.union([z5.string(), z5.null()]).optional(),
5242
- member_users: z5.union([z5.array(z5.string().uuid()), z5.null()]).optional(),
5243
- member_groups: z5.union([z5.array(z5.string().uuid()), z5.null()]).optional()
5244
- });
5245
- var IfExists = z5.enum(["error", "ignore", "replace"]);
5246
- var InvokeParent = z5.union([
5247
- z5.object({
5248
- object_type: z5.enum(["project_logs", "experiment", "playground_logs"]),
5249
- object_id: z5.string(),
5250
- row_ids: z5.union([
5251
- z5.object({
5252
- id: z5.string(),
5253
- span_id: z5.string(),
5254
- root_span_id: z5.string()
5307
+ var Group = z6.object({
5308
+ id: z6.string().uuid(),
5309
+ org_id: z6.string().uuid(),
5310
+ user_id: z6.union([z6.string(), z6.null()]).optional(),
5311
+ created: z6.union([z6.string(), z6.null()]).optional(),
5312
+ name: z6.string(),
5313
+ description: z6.union([z6.string(), z6.null()]).optional(),
5314
+ deleted_at: z6.union([z6.string(), z6.null()]).optional(),
5315
+ member_users: z6.union([z6.array(z6.string().uuid()), z6.null()]).optional(),
5316
+ member_groups: z6.union([z6.array(z6.string().uuid()), z6.null()]).optional()
5317
+ });
5318
+ var IfExists = z6.enum(["error", "ignore", "replace"]);
5319
+ var InvokeParent = z6.union([
5320
+ z6.object({
5321
+ object_type: z6.enum(["project_logs", "experiment", "playground_logs"]),
5322
+ object_id: z6.string(),
5323
+ row_ids: z6.union([
5324
+ z6.object({
5325
+ id: z6.string(),
5326
+ span_id: z6.string(),
5327
+ root_span_id: z6.string()
5255
5328
  }),
5256
- z5.null()
5329
+ z6.null()
5257
5330
  ]).optional(),
5258
- propagated_event: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
5331
+ propagated_event: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional()
5259
5332
  }),
5260
- z5.string()
5333
+ z6.string()
5261
5334
  ]);
5262
- var StreamingMode = z5.union([z5.enum(["auto", "parallel"]), z5.null()]);
5335
+ var StreamingMode = z6.union([z6.enum(["auto", "parallel"]), z6.null()]);
5263
5336
  var InvokeFunction = FunctionId.and(
5264
- z5.object({
5265
- input: z5.unknown(),
5266
- expected: z5.unknown(),
5267
- metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]),
5268
- tags: z5.union([z5.array(z5.string()), z5.null()]),
5269
- messages: z5.array(ChatCompletionMessageParam),
5337
+ z6.object({
5338
+ input: z6.unknown(),
5339
+ expected: z6.unknown(),
5340
+ metadata: z6.union([z6.object({}).partial().passthrough(), z6.null()]),
5341
+ tags: z6.union([z6.array(z6.string()), z6.null()]),
5342
+ messages: z6.array(ChatCompletionMessageParam),
5270
5343
  parent: InvokeParent,
5271
- stream: z5.union([z5.boolean(), z5.null()]),
5344
+ stream: z6.union([z6.boolean(), z6.null()]),
5272
5345
  mode: StreamingMode,
5273
- strict: z5.union([z5.boolean(), z5.null()])
5346
+ strict: z6.union([z6.boolean(), z6.null()])
5274
5347
  }).partial()
5275
5348
  );
5276
- var MessageRole = z5.enum([
5349
+ var MessageRole = z6.enum([
5277
5350
  "system",
5278
5351
  "user",
5279
5352
  "assistant",
@@ -5282,8 +5355,8 @@ var MessageRole = z5.enum([
5282
5355
  "model",
5283
5356
  "developer"
5284
5357
  ]);
5285
- var ObjectReference = z5.object({
5286
- object_type: z5.enum([
5358
+ var ObjectReference = z6.object({
5359
+ object_type: z6.enum([
5287
5360
  "project_logs",
5288
5361
  "experiment",
5289
5362
  "dataset",
@@ -5291,146 +5364,146 @@ var ObjectReference = z5.object({
5291
5364
  "function",
5292
5365
  "prompt_session"
5293
5366
  ]),
5294
- object_id: z5.string().uuid(),
5295
- id: z5.string(),
5296
- _xact_id: z5.union([z5.string(), z5.null()]).optional(),
5297
- created: z5.union([z5.string(), z5.null()]).optional()
5298
- });
5299
- var OnlineScoreConfig = z5.union([
5300
- z5.object({
5301
- sampling_rate: z5.number().gte(0).lte(1),
5302
- scorers: z5.array(SavedFunctionId),
5303
- btql_filter: z5.union([z5.string(), z5.null()]).optional(),
5304
- apply_to_root_span: z5.union([z5.boolean(), z5.null()]).optional(),
5305
- apply_to_span_names: z5.union([z5.array(z5.string()), z5.null()]).optional(),
5306
- skip_logging: z5.union([z5.boolean(), z5.null()]).optional()
5367
+ object_id: z6.string().uuid(),
5368
+ id: z6.string(),
5369
+ _xact_id: z6.union([z6.string(), z6.null()]).optional(),
5370
+ created: z6.union([z6.string(), z6.null()]).optional()
5371
+ });
5372
+ var OnlineScoreConfig = z6.union([
5373
+ z6.object({
5374
+ sampling_rate: z6.number().gte(0).lte(1),
5375
+ scorers: z6.array(SavedFunctionId),
5376
+ btql_filter: z6.union([z6.string(), z6.null()]).optional(),
5377
+ apply_to_root_span: z6.union([z6.boolean(), z6.null()]).optional(),
5378
+ apply_to_span_names: z6.union([z6.array(z6.string()), z6.null()]).optional(),
5379
+ skip_logging: z6.union([z6.boolean(), z6.null()]).optional()
5307
5380
  }),
5308
- z5.null()
5381
+ z6.null()
5309
5382
  ]);
5310
- var Organization = z5.object({
5311
- id: z5.string().uuid(),
5312
- name: z5.string(),
5313
- api_url: z5.union([z5.string(), z5.null()]).optional(),
5314
- is_universal_api: z5.union([z5.boolean(), z5.null()]).optional(),
5315
- proxy_url: z5.union([z5.string(), z5.null()]).optional(),
5316
- realtime_url: z5.union([z5.string(), z5.null()]).optional(),
5317
- created: z5.union([z5.string(), z5.null()]).optional()
5318
- });
5319
- var ProjectSettings = z5.union([
5320
- z5.object({
5321
- comparison_key: z5.union([z5.string(), z5.null()]),
5322
- baseline_experiment_id: z5.union([z5.string(), z5.null()]),
5323
- spanFieldOrder: z5.union([
5324
- z5.array(
5325
- z5.object({
5326
- object_type: z5.string(),
5327
- column_id: z5.string(),
5328
- position: z5.string(),
5329
- layout: z5.union([z5.literal("full"), z5.literal("two_column"), z5.null()]).optional()
5383
+ var Organization = z6.object({
5384
+ id: z6.string().uuid(),
5385
+ name: z6.string(),
5386
+ api_url: z6.union([z6.string(), z6.null()]).optional(),
5387
+ is_universal_api: z6.union([z6.boolean(), z6.null()]).optional(),
5388
+ proxy_url: z6.union([z6.string(), z6.null()]).optional(),
5389
+ realtime_url: z6.union([z6.string(), z6.null()]).optional(),
5390
+ created: z6.union([z6.string(), z6.null()]).optional()
5391
+ });
5392
+ var ProjectSettings = z6.union([
5393
+ z6.object({
5394
+ comparison_key: z6.union([z6.string(), z6.null()]),
5395
+ baseline_experiment_id: z6.union([z6.string(), z6.null()]),
5396
+ spanFieldOrder: z6.union([
5397
+ z6.array(
5398
+ z6.object({
5399
+ object_type: z6.string(),
5400
+ column_id: z6.string(),
5401
+ position: z6.string(),
5402
+ layout: z6.union([z6.literal("full"), z6.literal("two_column"), z6.null()]).optional()
5330
5403
  })
5331
5404
  ),
5332
- z5.null()
5405
+ z6.null()
5333
5406
  ]),
5334
- remote_eval_sources: z5.union([
5335
- z5.array(
5336
- z5.object({
5337
- url: z5.string(),
5338
- name: z5.string(),
5339
- description: z5.union([z5.string(), z5.null()]).optional()
5407
+ remote_eval_sources: z6.union([
5408
+ z6.array(
5409
+ z6.object({
5410
+ url: z6.string(),
5411
+ name: z6.string(),
5412
+ description: z6.union([z6.string(), z6.null()]).optional()
5340
5413
  })
5341
5414
  ),
5342
- z5.null()
5415
+ z6.null()
5343
5416
  ])
5344
5417
  }).partial(),
5345
- z5.null()
5418
+ z6.null()
5346
5419
  ]);
5347
- var Project = z5.object({
5348
- id: z5.string().uuid(),
5349
- org_id: z5.string().uuid(),
5350
- name: z5.string(),
5351
- created: z5.union([z5.string(), z5.null()]).optional(),
5352
- deleted_at: z5.union([z5.string(), z5.null()]).optional(),
5353
- user_id: z5.union([z5.string(), z5.null()]).optional(),
5420
+ var Project = z6.object({
5421
+ id: z6.string().uuid(),
5422
+ org_id: z6.string().uuid(),
5423
+ name: z6.string(),
5424
+ created: z6.union([z6.string(), z6.null()]).optional(),
5425
+ deleted_at: z6.union([z6.string(), z6.null()]).optional(),
5426
+ user_id: z6.union([z6.string(), z6.null()]).optional(),
5354
5427
  settings: ProjectSettings.optional()
5355
5428
  });
5356
- var RetentionObjectType = z5.enum([
5429
+ var RetentionObjectType = z6.enum([
5357
5430
  "project_logs",
5358
5431
  "experiment",
5359
5432
  "dataset"
5360
5433
  ]);
5361
- var ProjectAutomation = z5.object({
5362
- id: z5.string().uuid(),
5363
- project_id: z5.string().uuid(),
5364
- user_id: z5.union([z5.string(), z5.null()]).optional(),
5365
- created: z5.union([z5.string(), z5.null()]).optional(),
5366
- name: z5.string(),
5367
- description: z5.union([z5.string(), z5.null()]).optional(),
5368
- config: z5.union([
5369
- z5.object({
5370
- event_type: z5.literal("logs"),
5371
- btql_filter: z5.string(),
5372
- interval_seconds: z5.number().gte(1).lte(2592e3),
5373
- action: z5.object({ type: z5.literal("webhook"), url: z5.string() })
5434
+ var ProjectAutomation = z6.object({
5435
+ id: z6.string().uuid(),
5436
+ project_id: z6.string().uuid(),
5437
+ user_id: z6.union([z6.string(), z6.null()]).optional(),
5438
+ created: z6.union([z6.string(), z6.null()]).optional(),
5439
+ name: z6.string(),
5440
+ description: z6.union([z6.string(), z6.null()]).optional(),
5441
+ config: z6.union([
5442
+ z6.object({
5443
+ event_type: z6.literal("logs"),
5444
+ btql_filter: z6.string(),
5445
+ interval_seconds: z6.number().gte(1).lte(2592e3),
5446
+ action: z6.object({ type: z6.literal("webhook"), url: z6.string() })
5374
5447
  }),
5375
- z5.object({
5376
- event_type: z5.literal("btql_export"),
5377
- export_definition: z5.union([
5378
- z5.object({ type: z5.literal("log_traces") }),
5379
- z5.object({ type: z5.literal("log_spans") }),
5380
- z5.object({ type: z5.literal("btql_query"), btql_query: z5.string() })
5448
+ z6.object({
5449
+ event_type: z6.literal("btql_export"),
5450
+ export_definition: z6.union([
5451
+ z6.object({ type: z6.literal("log_traces") }),
5452
+ z6.object({ type: z6.literal("log_spans") }),
5453
+ z6.object({ type: z6.literal("btql_query"), btql_query: z6.string() })
5381
5454
  ]),
5382
- export_path: z5.string(),
5383
- format: z5.enum(["jsonl", "parquet"]),
5384
- interval_seconds: z5.number().gte(1).lte(2592e3),
5385
- credentials: z5.object({
5386
- type: z5.literal("aws_iam"),
5387
- role_arn: z5.string(),
5388
- external_id: z5.string()
5455
+ export_path: z6.string(),
5456
+ format: z6.enum(["jsonl", "parquet"]),
5457
+ interval_seconds: z6.number().gte(1).lte(2592e3),
5458
+ credentials: z6.object({
5459
+ type: z6.literal("aws_iam"),
5460
+ role_arn: z6.string(),
5461
+ external_id: z6.string()
5389
5462
  }),
5390
- batch_size: z5.union([z5.number(), z5.null()]).optional()
5463
+ batch_size: z6.union([z6.number(), z6.null()]).optional()
5391
5464
  }),
5392
- z5.object({
5393
- event_type: z5.literal("retention"),
5465
+ z6.object({
5466
+ event_type: z6.literal("retention"),
5394
5467
  object_type: RetentionObjectType,
5395
- retention_days: z5.number().gte(0)
5468
+ retention_days: z6.number().gte(0)
5396
5469
  })
5397
5470
  ])
5398
5471
  });
5399
- var ProjectLogsEvent = z5.object({
5400
- id: z5.string(),
5401
- _xact_id: z5.string(),
5402
- _pagination_key: z5.union([z5.string(), z5.null()]).optional(),
5403
- created: z5.string().datetime({ offset: true }),
5404
- org_id: z5.string().uuid(),
5405
- project_id: z5.string().uuid(),
5406
- log_id: z5.literal("g"),
5407
- input: z5.unknown().optional(),
5408
- output: z5.unknown().optional(),
5409
- expected: z5.unknown().optional(),
5410
- error: z5.unknown().optional(),
5411
- scores: z5.union([z5.record(z5.union([z5.number(), z5.null()])), z5.null()]).optional(),
5412
- metadata: z5.union([
5413
- z5.object({ model: z5.union([z5.string(), z5.null()]) }).partial().passthrough(),
5414
- z5.null()
5472
+ var ProjectLogsEvent = z6.object({
5473
+ id: z6.string(),
5474
+ _xact_id: z6.string(),
5475
+ _pagination_key: z6.union([z6.string(), z6.null()]).optional(),
5476
+ created: z6.string().datetime({ offset: true }),
5477
+ org_id: z6.string().uuid(),
5478
+ project_id: z6.string().uuid(),
5479
+ log_id: z6.literal("g"),
5480
+ input: z6.unknown().optional(),
5481
+ output: z6.unknown().optional(),
5482
+ expected: z6.unknown().optional(),
5483
+ error: z6.unknown().optional(),
5484
+ scores: z6.union([z6.record(z6.union([z6.number(), z6.null()])), z6.null()]).optional(),
5485
+ metadata: z6.union([
5486
+ z6.object({ model: z6.union([z6.string(), z6.null()]) }).partial().passthrough(),
5487
+ z6.null()
5415
5488
  ]).optional(),
5416
- tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
5417
- metrics: z5.union([z5.record(z5.number()), z5.null()]).optional(),
5418
- context: z5.union([
5419
- z5.object({
5420
- caller_functionname: z5.union([z5.string(), z5.null()]),
5421
- caller_filename: z5.union([z5.string(), z5.null()]),
5422
- caller_lineno: z5.union([z5.number(), z5.null()])
5489
+ tags: z6.union([z6.array(z6.string()), z6.null()]).optional(),
5490
+ metrics: z6.union([z6.record(z6.number()), z6.null()]).optional(),
5491
+ context: z6.union([
5492
+ z6.object({
5493
+ caller_functionname: z6.union([z6.string(), z6.null()]),
5494
+ caller_filename: z6.union([z6.string(), z6.null()]),
5495
+ caller_lineno: z6.union([z6.number(), z6.null()])
5423
5496
  }).partial().passthrough(),
5424
- z5.null()
5497
+ z6.null()
5425
5498
  ]).optional(),
5426
- span_id: z5.string(),
5427
- span_parents: z5.union([z5.array(z5.string()), z5.null()]).optional(),
5428
- root_span_id: z5.string(),
5429
- is_root: z5.union([z5.boolean(), z5.null()]).optional(),
5499
+ span_id: z6.string(),
5500
+ span_parents: z6.union([z6.array(z6.string()), z6.null()]).optional(),
5501
+ root_span_id: z6.string(),
5502
+ is_root: z6.union([z6.boolean(), z6.null()]).optional(),
5430
5503
  span_attributes: SpanAttributes.optional(),
5431
5504
  origin: ObjectReferenceNullish.optional()
5432
5505
  });
5433
- var ProjectScoreType = z5.enum([
5506
+ var ProjectScoreType = z6.enum([
5434
5507
  "slider",
5435
5508
  "categorical",
5436
5509
  "weighted",
@@ -5439,172 +5512,172 @@ var ProjectScoreType = z5.enum([
5439
5512
  "online",
5440
5513
  "free-form"
5441
5514
  ]);
5442
- var ProjectScoreCategory = z5.object({
5443
- name: z5.string(),
5444
- value: z5.number()
5445
- });
5446
- var ProjectScoreCategories = z5.union([
5447
- z5.array(ProjectScoreCategory),
5448
- z5.record(z5.number()),
5449
- z5.array(z5.string()),
5450
- z5.null()
5515
+ var ProjectScoreCategory = z6.object({
5516
+ name: z6.string(),
5517
+ value: z6.number()
5518
+ });
5519
+ var ProjectScoreCategories = z6.union([
5520
+ z6.array(ProjectScoreCategory),
5521
+ z6.record(z6.number()),
5522
+ z6.array(z6.string()),
5523
+ z6.null()
5451
5524
  ]);
5452
- var ProjectScoreConfig = z5.union([
5453
- z5.object({
5454
- multi_select: z5.union([z5.boolean(), z5.null()]),
5455
- destination: z5.union([z5.string(), z5.null()]),
5525
+ var ProjectScoreConfig = z6.union([
5526
+ z6.object({
5527
+ multi_select: z6.union([z6.boolean(), z6.null()]),
5528
+ destination: z6.union([z6.string(), z6.null()]),
5456
5529
  online: OnlineScoreConfig
5457
5530
  }).partial(),
5458
- z5.null()
5531
+ z6.null()
5459
5532
  ]);
5460
- var ProjectScore = z5.object({
5461
- id: z5.string().uuid(),
5462
- project_id: z5.string().uuid(),
5463
- user_id: z5.string().uuid(),
5464
- created: z5.union([z5.string(), z5.null()]).optional(),
5465
- name: z5.string(),
5466
- description: z5.union([z5.string(), z5.null()]).optional(),
5533
+ var ProjectScore = z6.object({
5534
+ id: z6.string().uuid(),
5535
+ project_id: z6.string().uuid(),
5536
+ user_id: z6.string().uuid(),
5537
+ created: z6.union([z6.string(), z6.null()]).optional(),
5538
+ name: z6.string(),
5539
+ description: z6.union([z6.string(), z6.null()]).optional(),
5467
5540
  score_type: ProjectScoreType,
5468
5541
  categories: ProjectScoreCategories.optional(),
5469
5542
  config: ProjectScoreConfig.optional(),
5470
- position: z5.union([z5.string(), z5.null()]).optional()
5471
- });
5472
- var ProjectTag = z5.object({
5473
- id: z5.string().uuid(),
5474
- project_id: z5.string().uuid(),
5475
- user_id: z5.string().uuid(),
5476
- created: z5.union([z5.string(), z5.null()]).optional(),
5477
- name: z5.string(),
5478
- description: z5.union([z5.string(), z5.null()]).optional(),
5479
- color: z5.union([z5.string(), z5.null()]).optional(),
5480
- position: z5.union([z5.string(), z5.null()]).optional()
5481
- });
5482
- var Prompt = z5.object({
5483
- id: z5.string().uuid(),
5484
- _xact_id: z5.string(),
5485
- project_id: z5.string().uuid(),
5486
- log_id: z5.literal("p"),
5487
- org_id: z5.string().uuid(),
5488
- name: z5.string(),
5489
- slug: z5.string(),
5490
- description: z5.union([z5.string(), z5.null()]).optional(),
5491
- created: z5.union([z5.string(), z5.null()]).optional(),
5543
+ position: z6.union([z6.string(), z6.null()]).optional()
5544
+ });
5545
+ var ProjectTag = z6.object({
5546
+ id: z6.string().uuid(),
5547
+ project_id: z6.string().uuid(),
5548
+ user_id: z6.string().uuid(),
5549
+ created: z6.union([z6.string(), z6.null()]).optional(),
5550
+ name: z6.string(),
5551
+ description: z6.union([z6.string(), z6.null()]).optional(),
5552
+ color: z6.union([z6.string(), z6.null()]).optional(),
5553
+ position: z6.union([z6.string(), z6.null()]).optional()
5554
+ });
5555
+ var Prompt = z6.object({
5556
+ id: z6.string().uuid(),
5557
+ _xact_id: z6.string(),
5558
+ project_id: z6.string().uuid(),
5559
+ log_id: z6.literal("p"),
5560
+ org_id: z6.string().uuid(),
5561
+ name: z6.string(),
5562
+ slug: z6.string(),
5563
+ description: z6.union([z6.string(), z6.null()]).optional(),
5564
+ created: z6.union([z6.string(), z6.null()]).optional(),
5492
5565
  prompt_data: PromptDataNullish.optional(),
5493
- tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
5494
- metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
5566
+ tags: z6.union([z6.array(z6.string()), z6.null()]).optional(),
5567
+ metadata: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional(),
5495
5568
  function_type: FunctionTypeEnumNullish.optional()
5496
5569
  });
5497
- var PromptOptions = z5.object({ model: z5.string(), params: ModelParams, position: z5.string() }).partial();
5498
- var PromptSessionEvent = z5.object({
5499
- id: z5.string(),
5500
- _xact_id: z5.string(),
5501
- created: z5.string().datetime({ offset: true }),
5502
- _pagination_key: z5.union([z5.string(), z5.null()]).optional(),
5503
- project_id: z5.string().uuid(),
5504
- prompt_session_id: z5.string().uuid(),
5505
- prompt_session_data: z5.unknown().optional(),
5506
- prompt_data: z5.unknown().optional(),
5507
- function_data: z5.unknown().optional(),
5570
+ var PromptOptions = z6.object({ model: z6.string(), params: ModelParams, position: z6.string() }).partial();
5571
+ var PromptSessionEvent = z6.object({
5572
+ id: z6.string(),
5573
+ _xact_id: z6.string(),
5574
+ created: z6.string().datetime({ offset: true }),
5575
+ _pagination_key: z6.union([z6.string(), z6.null()]).optional(),
5576
+ project_id: z6.string().uuid(),
5577
+ prompt_session_id: z6.string().uuid(),
5578
+ prompt_session_data: z6.unknown().optional(),
5579
+ prompt_data: z6.unknown().optional(),
5580
+ function_data: z6.unknown().optional(),
5508
5581
  function_type: FunctionTypeEnumNullish.optional(),
5509
- object_data: z5.unknown().optional(),
5510
- completion: z5.unknown().optional(),
5511
- tags: z5.union([z5.array(z5.string()), z5.null()]).optional()
5512
- });
5513
- var ResponseFormat = z5.union([
5514
- z5.object({ type: z5.literal("json_object") }),
5515
- z5.object({
5516
- type: z5.literal("json_schema"),
5582
+ object_data: z6.unknown().optional(),
5583
+ completion: z6.unknown().optional(),
5584
+ tags: z6.union([z6.array(z6.string()), z6.null()]).optional()
5585
+ });
5586
+ var ResponseFormat = z6.union([
5587
+ z6.object({ type: z6.literal("json_object") }),
5588
+ z6.object({
5589
+ type: z6.literal("json_schema"),
5517
5590
  json_schema: ResponseFormatJsonSchema
5518
5591
  }),
5519
- z5.object({ type: z5.literal("text") })
5592
+ z6.object({ type: z6.literal("text") })
5520
5593
  ]);
5521
- var Role = z5.object({
5522
- id: z5.string().uuid(),
5523
- org_id: z5.union([z5.string(), z5.null()]).optional(),
5524
- user_id: z5.union([z5.string(), z5.null()]).optional(),
5525
- created: z5.union([z5.string(), z5.null()]).optional(),
5526
- name: z5.string(),
5527
- description: z5.union([z5.string(), z5.null()]).optional(),
5528
- deleted_at: z5.union([z5.string(), z5.null()]).optional(),
5529
- member_permissions: z5.union([
5530
- z5.array(
5531
- z5.object({
5594
+ var Role = z6.object({
5595
+ id: z6.string().uuid(),
5596
+ org_id: z6.union([z6.string(), z6.null()]).optional(),
5597
+ user_id: z6.union([z6.string(), z6.null()]).optional(),
5598
+ created: z6.union([z6.string(), z6.null()]).optional(),
5599
+ name: z6.string(),
5600
+ description: z6.union([z6.string(), z6.null()]).optional(),
5601
+ deleted_at: z6.union([z6.string(), z6.null()]).optional(),
5602
+ member_permissions: z6.union([
5603
+ z6.array(
5604
+ z6.object({
5532
5605
  permission: Permission,
5533
5606
  restrict_object_type: AclObjectType.optional()
5534
5607
  })
5535
5608
  ),
5536
- z5.null()
5609
+ z6.null()
5537
5610
  ]).optional(),
5538
- member_roles: z5.union([z5.array(z5.string().uuid()), z5.null()]).optional()
5539
- });
5540
- var RunEval = z5.object({
5541
- project_id: z5.string(),
5542
- data: z5.union([
5543
- z5.object({
5544
- dataset_id: z5.string(),
5545
- _internal_btql: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
5611
+ member_roles: z6.union([z6.array(z6.string().uuid()), z6.null()]).optional()
5612
+ });
5613
+ var RunEval = z6.object({
5614
+ project_id: z6.string(),
5615
+ data: z6.union([
5616
+ z6.object({
5617
+ dataset_id: z6.string(),
5618
+ _internal_btql: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional()
5546
5619
  }),
5547
- z5.object({
5548
- project_name: z5.string(),
5549
- dataset_name: z5.string(),
5550
- _internal_btql: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
5620
+ z6.object({
5621
+ project_name: z6.string(),
5622
+ dataset_name: z6.string(),
5623
+ _internal_btql: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional()
5551
5624
  }),
5552
- z5.object({ data: z5.array(z5.unknown()) })
5625
+ z6.object({ data: z6.array(z6.unknown()) })
5553
5626
  ]),
5554
- task: FunctionId.and(z5.unknown()),
5555
- scores: z5.array(FunctionId),
5556
- experiment_name: z5.string().optional(),
5557
- metadata: z5.object({}).partial().passthrough().optional(),
5558
- parent: InvokeParent.and(z5.unknown()).optional(),
5559
- stream: z5.boolean().optional(),
5560
- trial_count: z5.union([z5.number(), z5.null()]).optional(),
5561
- is_public: z5.union([z5.boolean(), z5.null()]).optional(),
5562
- timeout: z5.union([z5.number(), z5.null()]).optional(),
5563
- max_concurrency: z5.union([z5.number(), z5.null()]).optional().default(10),
5564
- base_experiment_name: z5.union([z5.string(), z5.null()]).optional(),
5565
- base_experiment_id: z5.union([z5.string(), z5.null()]).optional(),
5627
+ task: FunctionId.and(z6.unknown()),
5628
+ scores: z6.array(FunctionId),
5629
+ experiment_name: z6.string().optional(),
5630
+ metadata: z6.object({}).partial().passthrough().optional(),
5631
+ parent: InvokeParent.and(z6.unknown()).optional(),
5632
+ stream: z6.boolean().optional(),
5633
+ trial_count: z6.union([z6.number(), z6.null()]).optional(),
5634
+ is_public: z6.union([z6.boolean(), z6.null()]).optional(),
5635
+ timeout: z6.union([z6.number(), z6.null()]).optional(),
5636
+ max_concurrency: z6.union([z6.number(), z6.null()]).optional().default(10),
5637
+ base_experiment_name: z6.union([z6.string(), z6.null()]).optional(),
5638
+ base_experiment_id: z6.union([z6.string(), z6.null()]).optional(),
5566
5639
  git_metadata_settings: GitMetadataSettings.and(
5567
- z5.union([z5.object({}).partial(), z5.null()])
5640
+ z6.union([z6.object({}).partial(), z6.null()])
5568
5641
  ).optional(),
5569
- repo_info: RepoInfo.and(z5.unknown()).optional(),
5570
- strict: z5.union([z5.boolean(), z5.null()]).optional(),
5571
- stop_token: z5.union([z5.string(), z5.null()]).optional(),
5572
- extra_messages: z5.string().optional(),
5573
- tags: z5.array(z5.string()).optional()
5574
- });
5575
- var ServiceToken = z5.object({
5576
- id: z5.string().uuid(),
5577
- created: z5.union([z5.string(), z5.null()]).optional(),
5578
- name: z5.string(),
5579
- preview_name: z5.string(),
5580
- service_account_id: z5.union([z5.string(), z5.null()]).optional(),
5581
- service_account_email: z5.union([z5.string(), z5.null()]).optional(),
5582
- service_account_name: z5.union([z5.string(), z5.null()]).optional(),
5583
- org_id: z5.union([z5.string(), z5.null()]).optional()
5584
- });
5585
- var SpanIFrame = z5.object({
5586
- id: z5.string().uuid(),
5587
- project_id: z5.string().uuid(),
5588
- user_id: z5.union([z5.string(), z5.null()]).optional(),
5589
- created: z5.union([z5.string(), z5.null()]).optional(),
5590
- deleted_at: z5.union([z5.string(), z5.null()]).optional(),
5591
- name: z5.string(),
5592
- description: z5.union([z5.string(), z5.null()]).optional(),
5593
- url: z5.string(),
5594
- post_message: z5.union([z5.boolean(), z5.null()]).optional()
5595
- });
5596
- var SSEConsoleEventData = z5.object({
5597
- stream: z5.enum(["stderr", "stdout"]),
5598
- message: z5.string()
5599
- });
5600
- var SSEProgressEventData = z5.object({
5601
- id: z5.string(),
5642
+ repo_info: RepoInfo.and(z6.unknown()).optional(),
5643
+ strict: z6.union([z6.boolean(), z6.null()]).optional(),
5644
+ stop_token: z6.union([z6.string(), z6.null()]).optional(),
5645
+ extra_messages: z6.string().optional(),
5646
+ tags: z6.array(z6.string()).optional()
5647
+ });
5648
+ var ServiceToken = z6.object({
5649
+ id: z6.string().uuid(),
5650
+ created: z6.union([z6.string(), z6.null()]).optional(),
5651
+ name: z6.string(),
5652
+ preview_name: z6.string(),
5653
+ service_account_id: z6.union([z6.string(), z6.null()]).optional(),
5654
+ service_account_email: z6.union([z6.string(), z6.null()]).optional(),
5655
+ service_account_name: z6.union([z6.string(), z6.null()]).optional(),
5656
+ org_id: z6.union([z6.string(), z6.null()]).optional()
5657
+ });
5658
+ var SpanIFrame = z6.object({
5659
+ id: z6.string().uuid(),
5660
+ project_id: z6.string().uuid(),
5661
+ user_id: z6.union([z6.string(), z6.null()]).optional(),
5662
+ created: z6.union([z6.string(), z6.null()]).optional(),
5663
+ deleted_at: z6.union([z6.string(), z6.null()]).optional(),
5664
+ name: z6.string(),
5665
+ description: z6.union([z6.string(), z6.null()]).optional(),
5666
+ url: z6.string(),
5667
+ post_message: z6.union([z6.boolean(), z6.null()]).optional()
5668
+ });
5669
+ var SSEConsoleEventData = z6.object({
5670
+ stream: z6.enum(["stderr", "stdout"]),
5671
+ message: z6.string()
5672
+ });
5673
+ var SSEProgressEventData = z6.object({
5674
+ id: z6.string(),
5602
5675
  object_type: FunctionObjectType,
5603
- origin: ObjectReferenceNullish.and(z5.unknown()).optional(),
5676
+ origin: ObjectReferenceNullish.and(z6.unknown()).optional(),
5604
5677
  format: FunctionFormat,
5605
5678
  output_type: FunctionOutputType,
5606
- name: z5.string(),
5607
- event: z5.enum([
5679
+ name: z6.string(),
5680
+ event: z6.enum([
5608
5681
  "reasoning_delta",
5609
5682
  "text_delta",
5610
5683
  "json_delta",
@@ -5614,110 +5687,110 @@ var SSEProgressEventData = z5.object({
5614
5687
  "done",
5615
5688
  "progress"
5616
5689
  ]),
5617
- data: z5.string()
5618
- });
5619
- var ToolFunctionDefinition = z5.object({
5620
- type: z5.literal("function"),
5621
- function: z5.object({
5622
- name: z5.string(),
5623
- description: z5.string().optional(),
5624
- parameters: z5.object({}).partial().passthrough().optional(),
5625
- strict: z5.union([z5.boolean(), z5.null()]).optional()
5690
+ data: z6.string()
5691
+ });
5692
+ var ToolFunctionDefinition = z6.object({
5693
+ type: z6.literal("function"),
5694
+ function: z6.object({
5695
+ name: z6.string(),
5696
+ description: z6.string().optional(),
5697
+ parameters: z6.object({}).partial().passthrough().optional(),
5698
+ strict: z6.union([z6.boolean(), z6.null()]).optional()
5626
5699
  })
5627
5700
  });
5628
- var User = z5.object({
5629
- id: z5.string().uuid(),
5630
- given_name: z5.union([z5.string(), z5.null()]).optional(),
5631
- family_name: z5.union([z5.string(), z5.null()]).optional(),
5632
- email: z5.union([z5.string(), z5.null()]).optional(),
5633
- avatar_url: z5.union([z5.string(), z5.null()]).optional(),
5634
- created: z5.union([z5.string(), z5.null()]).optional()
5635
- });
5636
- var ViewDataSearch = z5.union([
5637
- z5.object({
5638
- filter: z5.union([z5.array(z5.unknown()), z5.null()]),
5639
- tag: z5.union([z5.array(z5.unknown()), z5.null()]),
5640
- match: z5.union([z5.array(z5.unknown()), z5.null()]),
5641
- sort: z5.union([z5.array(z5.unknown()), z5.null()])
5701
+ var User = z6.object({
5702
+ id: z6.string().uuid(),
5703
+ given_name: z6.union([z6.string(), z6.null()]).optional(),
5704
+ family_name: z6.union([z6.string(), z6.null()]).optional(),
5705
+ email: z6.union([z6.string(), z6.null()]).optional(),
5706
+ avatar_url: z6.union([z6.string(), z6.null()]).optional(),
5707
+ created: z6.union([z6.string(), z6.null()]).optional()
5708
+ });
5709
+ var ViewDataSearch = z6.union([
5710
+ z6.object({
5711
+ filter: z6.union([z6.array(z6.unknown()), z6.null()]),
5712
+ tag: z6.union([z6.array(z6.unknown()), z6.null()]),
5713
+ match: z6.union([z6.array(z6.unknown()), z6.null()]),
5714
+ sort: z6.union([z6.array(z6.unknown()), z6.null()])
5642
5715
  }).partial(),
5643
- z5.null()
5716
+ z6.null()
5644
5717
  ]);
5645
- var ViewData = z5.union([
5646
- z5.object({ search: ViewDataSearch }).partial(),
5647
- z5.null()
5718
+ var ViewData = z6.union([
5719
+ z6.object({ search: ViewDataSearch }).partial(),
5720
+ z6.null()
5648
5721
  ]);
5649
- var ViewOptions = z5.union([
5650
- z5.object({
5651
- viewType: z5.literal("monitor"),
5652
- options: z5.object({
5653
- spanType: z5.union([z5.enum(["range", "frame"]), z5.null()]),
5654
- rangeValue: z5.union([z5.string(), z5.null()]),
5655
- frameStart: z5.union([z5.string(), z5.null()]),
5656
- frameEnd: z5.union([z5.string(), z5.null()]),
5657
- tzUTC: z5.union([z5.boolean(), z5.null()]),
5658
- chartVisibility: z5.union([z5.record(z5.boolean()), z5.null()]),
5659
- projectId: z5.union([z5.string(), z5.null()]),
5660
- type: z5.union([z5.enum(["project", "experiment"]), z5.null()]),
5661
- groupBy: z5.union([z5.string(), z5.null()])
5722
+ var ViewOptions = z6.union([
5723
+ z6.object({
5724
+ viewType: z6.literal("monitor"),
5725
+ options: z6.object({
5726
+ spanType: z6.union([z6.enum(["range", "frame"]), z6.null()]),
5727
+ rangeValue: z6.union([z6.string(), z6.null()]),
5728
+ frameStart: z6.union([z6.string(), z6.null()]),
5729
+ frameEnd: z6.union([z6.string(), z6.null()]),
5730
+ tzUTC: z6.union([z6.boolean(), z6.null()]),
5731
+ chartVisibility: z6.union([z6.record(z6.boolean()), z6.null()]),
5732
+ projectId: z6.union([z6.string(), z6.null()]),
5733
+ type: z6.union([z6.enum(["project", "experiment"]), z6.null()]),
5734
+ groupBy: z6.union([z6.string(), z6.null()])
5662
5735
  }).partial()
5663
5736
  }),
5664
- z5.object({
5665
- columnVisibility: z5.union([z5.record(z5.boolean()), z5.null()]),
5666
- columnOrder: z5.union([z5.array(z5.string()), z5.null()]),
5667
- columnSizing: z5.union([z5.record(z5.number()), z5.null()]),
5668
- grouping: z5.union([z5.string(), z5.null()]),
5669
- rowHeight: z5.union([z5.string(), z5.null()]),
5670
- tallGroupRows: z5.union([z5.boolean(), z5.null()]),
5671
- layout: z5.union([z5.string(), z5.null()]),
5672
- chartHeight: z5.union([z5.number(), z5.null()]),
5673
- excludedMeasures: z5.union([
5674
- z5.array(
5675
- z5.object({
5676
- type: z5.enum(["none", "score", "metric", "metadata"]),
5677
- value: z5.string()
5737
+ z6.object({
5738
+ columnVisibility: z6.union([z6.record(z6.boolean()), z6.null()]),
5739
+ columnOrder: z6.union([z6.array(z6.string()), z6.null()]),
5740
+ columnSizing: z6.union([z6.record(z6.number()), z6.null()]),
5741
+ grouping: z6.union([z6.string(), z6.null()]),
5742
+ rowHeight: z6.union([z6.string(), z6.null()]),
5743
+ tallGroupRows: z6.union([z6.boolean(), z6.null()]),
5744
+ layout: z6.union([z6.string(), z6.null()]),
5745
+ chartHeight: z6.union([z6.number(), z6.null()]),
5746
+ excludedMeasures: z6.union([
5747
+ z6.array(
5748
+ z6.object({
5749
+ type: z6.enum(["none", "score", "metric", "metadata"]),
5750
+ value: z6.string()
5678
5751
  })
5679
5752
  ),
5680
- z5.null()
5753
+ z6.null()
5681
5754
  ]),
5682
- yMetric: z5.union([
5683
- z5.object({
5684
- type: z5.enum(["none", "score", "metric", "metadata"]),
5685
- value: z5.string()
5755
+ yMetric: z6.union([
5756
+ z6.object({
5757
+ type: z6.enum(["none", "score", "metric", "metadata"]),
5758
+ value: z6.string()
5686
5759
  }),
5687
- z5.null()
5760
+ z6.null()
5688
5761
  ]),
5689
- xAxis: z5.union([
5690
- z5.object({
5691
- type: z5.enum(["none", "score", "metric", "metadata"]),
5692
- value: z5.string()
5762
+ xAxis: z6.union([
5763
+ z6.object({
5764
+ type: z6.enum(["none", "score", "metric", "metadata"]),
5765
+ value: z6.string()
5693
5766
  }),
5694
- z5.null()
5767
+ z6.null()
5695
5768
  ]),
5696
- symbolGrouping: z5.union([
5697
- z5.object({
5698
- type: z5.enum(["none", "score", "metric", "metadata"]),
5699
- value: z5.string()
5769
+ symbolGrouping: z6.union([
5770
+ z6.object({
5771
+ type: z6.enum(["none", "score", "metric", "metadata"]),
5772
+ value: z6.string()
5700
5773
  }),
5701
- z5.null()
5774
+ z6.null()
5702
5775
  ]),
5703
- xAxisAggregation: z5.union([z5.string(), z5.null()]),
5704
- chartAnnotations: z5.union([
5705
- z5.array(z5.object({ id: z5.string(), text: z5.string() })),
5706
- z5.null()
5776
+ xAxisAggregation: z6.union([z6.string(), z6.null()]),
5777
+ chartAnnotations: z6.union([
5778
+ z6.array(z6.object({ id: z6.string(), text: z6.string() })),
5779
+ z6.null()
5707
5780
  ]),
5708
- timeRangeFilter: z5.union([
5709
- z5.string(),
5710
- z5.object({ from: z5.string(), to: z5.string() }),
5711
- z5.null()
5781
+ timeRangeFilter: z6.union([
5782
+ z6.string(),
5783
+ z6.object({ from: z6.string(), to: z6.string() }),
5784
+ z6.null()
5712
5785
  ])
5713
5786
  }).partial(),
5714
- z5.null()
5787
+ z6.null()
5715
5788
  ]);
5716
- var View = z5.object({
5717
- id: z5.string().uuid(),
5718
- object_type: AclObjectType.and(z5.string()),
5719
- object_id: z5.string().uuid(),
5720
- view_type: z5.enum([
5789
+ var View = z6.object({
5790
+ id: z6.string().uuid(),
5791
+ object_type: AclObjectType.and(z6.string()),
5792
+ object_id: z6.string().uuid(),
5793
+ view_type: z6.enum([
5721
5794
  "projects",
5722
5795
  "experiments",
5723
5796
  "experiment",
@@ -5732,56 +5805,56 @@ var View = z5.object({
5732
5805
  "agents",
5733
5806
  "monitor"
5734
5807
  ]),
5735
- name: z5.string(),
5736
- created: z5.union([z5.string(), z5.null()]).optional(),
5808
+ name: z6.string(),
5809
+ created: z6.union([z6.string(), z6.null()]).optional(),
5737
5810
  view_data: ViewData.optional(),
5738
5811
  options: ViewOptions.optional(),
5739
- user_id: z5.union([z5.string(), z5.null()]).optional(),
5740
- deleted_at: z5.union([z5.string(), z5.null()]).optional()
5812
+ user_id: z6.union([z6.string(), z6.null()]).optional(),
5813
+ deleted_at: z6.union([z6.string(), z6.null()]).optional()
5741
5814
  });
5742
5815
 
5743
5816
  // src/logger.ts
5744
5817
  import { waitUntil } from "@vercel/functions";
5745
5818
  import Mustache2 from "mustache";
5746
- import { z as z7, ZodError } from "zod";
5819
+ import { z as z8, ZodError } from "zod";
5747
5820
 
5748
5821
  // src/functions/stream.ts
5749
5822
  import {
5750
5823
  createParser
5751
5824
  } from "eventsource-parser";
5752
- import { z as z6 } from "zod/v3";
5753
- var braintrustStreamChunkSchema = z6.union([
5754
- z6.object({
5755
- type: z6.literal("text_delta"),
5756
- data: z6.string()
5825
+ import { z as z7 } from "zod/v3";
5826
+ var braintrustStreamChunkSchema = z7.union([
5827
+ z7.object({
5828
+ type: z7.literal("text_delta"),
5829
+ data: z7.string()
5757
5830
  }),
5758
- z6.object({
5759
- type: z6.literal("reasoning_delta"),
5760
- data: z6.string()
5831
+ z7.object({
5832
+ type: z7.literal("reasoning_delta"),
5833
+ data: z7.string()
5761
5834
  }),
5762
- z6.object({
5763
- type: z6.literal("json_delta"),
5764
- data: z6.string()
5835
+ z7.object({
5836
+ type: z7.literal("json_delta"),
5837
+ data: z7.string()
5765
5838
  }),
5766
- z6.object({
5767
- type: z6.literal("error"),
5768
- data: z6.string()
5839
+ z7.object({
5840
+ type: z7.literal("error"),
5841
+ data: z7.string()
5769
5842
  }),
5770
- z6.object({
5771
- type: z6.literal("console"),
5843
+ z7.object({
5844
+ type: z7.literal("console"),
5772
5845
  data: SSEConsoleEventData
5773
5846
  }),
5774
- z6.object({
5775
- type: z6.literal("progress"),
5847
+ z7.object({
5848
+ type: z7.literal("progress"),
5776
5849
  data: SSEProgressEventData
5777
5850
  }),
5778
- z6.object({
5779
- type: z6.literal("start"),
5780
- data: z6.string()
5851
+ z7.object({
5852
+ type: z7.literal("start"),
5853
+ data: z7.string()
5781
5854
  }),
5782
- z6.object({
5783
- type: z6.literal("done"),
5784
- data: z6.string()
5855
+ z7.object({
5856
+ type: z7.literal("done"),
5857
+ data: z7.string()
5785
5858
  })
5786
5859
  ]);
5787
5860
  var BraintrustStream = class _BraintrustStream {
@@ -6484,17 +6557,31 @@ var NoopSpan = class {
6484
6557
  state() {
6485
6558
  return _internalGetGlobalState();
6486
6559
  }
6560
+ // Custom inspect for Node.js console.log
6561
+ [Symbol.for("nodejs.util.inspect.custom")]() {
6562
+ return `NoopSpan {
6563
+ kind: '${this.kind}',
6564
+ id: '${this.id}',
6565
+ spanId: '${this.spanId}',
6566
+ rootSpanId: '${this.rootSpanId}',
6567
+ spanParents: ${JSON.stringify(this.spanParents)}
6568
+ }`;
6569
+ }
6570
+ // Custom toString
6571
+ toString() {
6572
+ return `NoopSpan(id=${this.id}, spanId=${this.spanId})`;
6573
+ }
6487
6574
  };
6488
6575
  var NOOP_SPAN = new NoopSpan();
6489
6576
  var NOOP_SPAN_PERMALINK = "https://braintrust.dev/noop-span";
6490
- var loginSchema = z7.strictObject({
6491
- appUrl: z7.string(),
6492
- appPublicUrl: z7.string(),
6493
- orgName: z7.string(),
6494
- apiUrl: z7.string(),
6495
- proxyUrl: z7.string(),
6496
- loginToken: z7.string(),
6497
- orgId: z7.string().nullish(),
6577
+ var loginSchema = z8.strictObject({
6578
+ appUrl: z8.string(),
6579
+ appPublicUrl: z8.string(),
6580
+ orgName: z8.string(),
6581
+ apiUrl: z8.string(),
6582
+ proxyUrl: z8.string(),
6583
+ loginToken: z8.string(),
6584
+ orgId: z8.string().nullish(),
6498
6585
  gitMetadataSettings: GitMetadataSettings.nullish()
6499
6586
  });
6500
6587
  var stateNonce = 0;
@@ -6553,6 +6640,7 @@ var BraintrustState = class _BraintrustState {
6553
6640
  _apiConn = null;
6554
6641
  _proxyConn = null;
6555
6642
  promptCache;
6643
+ _idGenerator = null;
6556
6644
  resetLoginInfo() {
6557
6645
  this.appUrl = null;
6558
6646
  this.appPublicUrl = null;
@@ -6567,6 +6655,15 @@ var BraintrustState = class _BraintrustState {
6567
6655
  this._apiConn = null;
6568
6656
  this._proxyConn = null;
6569
6657
  }
6658
+ resetIdGenState() {
6659
+ this._idGenerator = null;
6660
+ }
6661
+ get idGenerator() {
6662
+ if (this._idGenerator === null) {
6663
+ this._idGenerator = getIdGenerator();
6664
+ }
6665
+ return this._idGenerator;
6666
+ }
6570
6667
  copyLoginInfo(other) {
6571
6668
  this.appUrl = other.appUrl;
6572
6669
  this.appPublicUrl = other.appPublicUrl;
@@ -6704,6 +6801,37 @@ var BraintrustState = class _BraintrustState {
6704
6801
  enforceQueueSizeLimit(enforce) {
6705
6802
  this._bgLogger.get().enforceQueueSizeLimit(enforce);
6706
6803
  }
6804
+ // Custom serialization to avoid logging sensitive data
6805
+ toJSON() {
6806
+ return {
6807
+ id: this.id,
6808
+ orgId: this.orgId,
6809
+ orgName: this.orgName,
6810
+ appUrl: this.appUrl,
6811
+ appPublicUrl: this.appPublicUrl,
6812
+ apiUrl: this.apiUrl,
6813
+ proxyUrl: this.proxyUrl,
6814
+ loggedIn: this.loggedIn
6815
+ // Explicitly exclude loginToken, _apiConn, _appConn, _proxyConn and other sensitive fields
6816
+ };
6817
+ }
6818
+ // Custom inspect for Node.js console.log
6819
+ [Symbol.for("nodejs.util.inspect.custom")]() {
6820
+ return `BraintrustState {
6821
+ id: '${this.id}',
6822
+ orgId: ${this.orgId ? `'${this.orgId}'` : "null"},
6823
+ orgName: ${this.orgName ? `'${this.orgName}'` : "null"},
6824
+ appUrl: ${this.appUrl ? `'${this.appUrl}'` : "null"},
6825
+ apiUrl: ${this.apiUrl ? `'${this.apiUrl}'` : "null"},
6826
+ proxyUrl: ${this.proxyUrl ? `'${this.proxyUrl}'` : "null"},
6827
+ loggedIn: ${this.loggedIn},
6828
+ loginToken: '[REDACTED]'
6829
+ }`;
6830
+ }
6831
+ // Custom toString
6832
+ toString() {
6833
+ return `BraintrustState(id=${this.id}, org=${this.orgName || "none"}, loggedIn=${this.loggedIn})`;
6834
+ }
6707
6835
  };
6708
6836
  var _globalState;
6709
6837
  function useTestBackgroundLogger() {
@@ -6871,6 +6999,17 @@ var HTTPConnection = class _HTTPConnection {
6871
6999
  });
6872
7000
  return await resp.json();
6873
7001
  }
7002
+ // Custom inspect for Node.js console.log
7003
+ [Symbol.for("nodejs.util.inspect.custom")]() {
7004
+ return `HTTPConnection {
7005
+ base_url: '${this.base_url}',
7006
+ token: '[REDACTED]'
7007
+ }`;
7008
+ }
7009
+ // Custom toString
7010
+ toString() {
7011
+ return `HTTPConnection(${this.base_url})`;
7012
+ }
6874
7013
  };
6875
7014
  var BaseAttachment = class {
6876
7015
  reference;
@@ -6971,9 +7110,9 @@ var Attachment = class extends BaseAttachment {
6971
7110
  let signedUrl;
6972
7111
  let headers;
6973
7112
  try {
6974
- ({ signedUrl, headers } = z7.object({
6975
- signedUrl: z7.string().url(),
6976
- headers: z7.record(z7.string())
7113
+ ({ signedUrl, headers } = z8.object({
7114
+ signedUrl: z8.string().url(),
7115
+ headers: z8.record(z8.string())
6977
7116
  }).parse(await metadataResponse.json()));
6978
7117
  } catch (error2) {
6979
7118
  if (error2 instanceof ZodError) {
@@ -7128,8 +7267,8 @@ var ExternalAttachment = class extends BaseAttachment {
7128
7267
  });
7129
7268
  }
7130
7269
  };
7131
- var attachmentMetadataSchema = z7.object({
7132
- downloadUrl: z7.string(),
7270
+ var attachmentMetadataSchema = z8.object({
7271
+ downloadUrl: z8.string(),
7133
7272
  status: AttachmentStatus
7134
7273
  });
7135
7274
  var ReadonlyAttachment = class {
@@ -7267,7 +7406,7 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
7267
7406
  if (!isEmpty(comment)) {
7268
7407
  const record = new LazyValue(async () => {
7269
7408
  return {
7270
- id: uuidv4(),
7409
+ id: uuidv42(),
7271
7410
  created: (/* @__PURE__ */ new Date()).toISOString(),
7272
7411
  origin: {
7273
7412
  // NOTE: We do not know (or care?) what the transaction id of the row that
@@ -8057,7 +8196,7 @@ Error: ${errorText}`;
8057
8196
  }
8058
8197
  const payloadFile = isomorph_default.pathJoin(
8059
8198
  payloadDir,
8060
- `payload_${getCurrentUnixTimestamp()}_${uuidv4().slice(0, 8)}.json`
8199
+ `payload_${getCurrentUnixTimestamp()}_${uuidv42().slice(0, 8)}.json`
8061
8200
  );
8062
8201
  try {
8063
8202
  await isomorph_default.mkdir(payloadDir, { recursive: true });
@@ -9109,7 +9248,7 @@ function validateAndSanitizeExperimentLogPartialArgs(event) {
9109
9248
  function deepCopyEvent(event) {
9110
9249
  const attachments = [];
9111
9250
  const IDENTIFIER = "_bt_internal_saved_attachment";
9112
- const savedAttachmentSchema = z7.strictObject({ [IDENTIFIER]: z7.number() });
9251
+ const savedAttachmentSchema = z8.strictObject({ [IDENTIFIER]: z8.number() });
9113
9252
  const serialized = JSON.stringify(event, (_k, v) => {
9114
9253
  if (v instanceof SpanImpl || v instanceof NoopSpan) {
9115
9254
  return `<span>`;
@@ -9612,7 +9751,7 @@ var ReadonlyExperiment = class extends ObjectFetcher {
9612
9751
  };
9613
9752
  var executionCounter = 0;
9614
9753
  function newId() {
9615
- return uuidv4();
9754
+ return uuidv42();
9616
9755
  }
9617
9756
  var SpanImpl = class _SpanImpl {
9618
9757
  _state;
@@ -9668,13 +9807,17 @@ var SpanImpl = class _SpanImpl {
9668
9807
  },
9669
9808
  created: (/* @__PURE__ */ new Date()).toISOString()
9670
9809
  };
9671
- this._id = eventId ?? uuidv4();
9672
- this._spanId = args.spanId ?? uuidv4();
9810
+ this._id = eventId ?? this._state.idGenerator.getSpanId();
9811
+ this._spanId = args.spanId ?? this._state.idGenerator.getSpanId();
9673
9812
  if (args.parentSpanIds) {
9674
9813
  this._rootSpanId = args.parentSpanIds.rootSpanId;
9675
9814
  this._spanParents = "parentSpanIds" in args.parentSpanIds ? args.parentSpanIds.parentSpanIds : [args.parentSpanIds.spanId];
9676
9815
  } else {
9677
- this._rootSpanId = this._spanId;
9816
+ if (this._state.idGenerator.shareRootSpanId()) {
9817
+ this._rootSpanId = this._spanId;
9818
+ } else {
9819
+ this._rootSpanId = this._state.idGenerator.getTraceId();
9820
+ }
9678
9821
  this._spanParents = void 0;
9679
9822
  }
9680
9823
  this.isMerge = false;
@@ -9885,6 +10028,20 @@ var SpanImpl = class _SpanImpl {
9885
10028
  state() {
9886
10029
  return this._state;
9887
10030
  }
10031
+ // Custom inspect for Node.js console.log
10032
+ [Symbol.for("nodejs.util.inspect.custom")]() {
10033
+ return `SpanImpl {
10034
+ kind: '${this.kind}',
10035
+ id: '${this.id}',
10036
+ spanId: '${this.spanId}',
10037
+ rootSpanId: '${this.rootSpanId}',
10038
+ spanParents: ${JSON.stringify(this.spanParents)}
10039
+ }`;
10040
+ }
10041
+ // Custom toString
10042
+ toString() {
10043
+ return `SpanImpl(id=${this.id}, spanId=${this.spanId})`;
10044
+ }
9888
10045
  };
9889
10046
  function splitLoggingData({
9890
10047
  event,
@@ -10036,7 +10193,7 @@ var Dataset2 = class extends ObjectFetcher {
10036
10193
  output
10037
10194
  }) {
10038
10195
  this.validateEvent({ metadata, expected, output, tags });
10039
- const rowId = id || uuidv4();
10196
+ const rowId = id || uuidv42();
10040
10197
  const args = this.createArgs(
10041
10198
  deepCopyEvent({
10042
10199
  id: rowId,
@@ -10114,8 +10271,8 @@ var Dataset2 = class extends ObjectFetcher {
10114
10271
  )}`;
10115
10272
  let dataSummary;
10116
10273
  if (summarizeData) {
10117
- const rawDataSummary = z7.object({
10118
- total_records: z7.number()
10274
+ const rawDataSummary = z8.object({
10275
+ total_records: z8.number()
10119
10276
  }).parse(
10120
10277
  await state.apiConn().get_json(
10121
10278
  "dataset-summary",
@@ -10238,11 +10395,11 @@ function renderTemplatedObject(obj, args, options) {
10238
10395
  return obj;
10239
10396
  }
10240
10397
  function renderPromptParams(params, args, options) {
10241
- const schemaParsed = z7.object({
10242
- response_format: z7.object({
10243
- type: z7.literal("json_schema"),
10398
+ const schemaParsed = z8.object({
10399
+ response_format: z8.object({
10400
+ type: z8.literal("json_schema"),
10244
10401
  json_schema: ResponseFormatJsonSchema.omit({ schema: true }).extend({
10245
- schema: z7.unknown()
10402
+ schema: z8.unknown()
10246
10403
  })
10247
10404
  })
10248
10405
  }).safeParse(params);
@@ -10360,7 +10517,7 @@ var Prompt2 = class _Prompt {
10360
10517
  if (!prompt) {
10361
10518
  throw new Error("Empty prompt");
10362
10519
  }
10363
- const dictArgParsed = z7.record(z7.unknown()).safeParse(buildArgs);
10520
+ const dictArgParsed = z8.record(z8.unknown()).safeParse(buildArgs);
10364
10521
  const variables = {
10365
10522
  input: buildArgs,
10366
10523
  ...dictArgParsed.success ? dictArgParsed.data : {}
@@ -10415,7 +10572,7 @@ var Prompt2 = class _Prompt {
10415
10572
  return JSON.stringify(v);
10416
10573
  }
10417
10574
  };
10418
- const dictArgParsed = z7.record(z7.unknown()).safeParse(buildArgs);
10575
+ const dictArgParsed = z8.record(z8.unknown()).safeParse(buildArgs);
10419
10576
  const variables = {
10420
10577
  input: buildArgs,
10421
10578
  ...dictArgParsed.success ? dictArgParsed.data : {}
@@ -10556,6 +10713,12 @@ async function getPromptVersions(projectId, promptId) {
10556
10713
  (entry) => ["upsert", "merge"].includes(entry.audit_data?.action)
10557
10714
  ).map((entry) => prettifyXact(entry._xact_id)) || [];
10558
10715
  }
10716
+ function resetIdGenStateForTests() {
10717
+ const state = _internalGetGlobalState();
10718
+ if (state) {
10719
+ state.resetIdGenState();
10720
+ }
10721
+ }
10559
10722
  var _exportsForTestingOnly = {
10560
10723
  extractAttachments,
10561
10724
  deepCopyEvent,
@@ -10566,7 +10729,8 @@ var _exportsForTestingOnly = {
10566
10729
  setInitialTestState,
10567
10730
  initTestExperiment,
10568
10731
  isGeneratorFunction,
10569
- isAsyncGeneratorFunction
10732
+ isAsyncGeneratorFunction,
10733
+ resetIdGenStateForTests
10570
10734
  };
10571
10735
 
10572
10736
  // src/node.ts
@@ -10619,6 +10783,7 @@ __export(exports_node_exports, {
10619
10783
  Experiment: () => Experiment2,
10620
10784
  ExternalAttachment: () => ExternalAttachment,
10621
10785
  FailedHTTPResponse: () => FailedHTTPResponse,
10786
+ IDGenerator: () => IDGenerator,
10622
10787
  INTERNAL_BTQL_LIMIT: () => INTERNAL_BTQL_LIMIT,
10623
10788
  LEGACY_CACHED_HEADER: () => LEGACY_CACHED_HEADER,
10624
10789
  LazyValue: () => LazyValue,
@@ -10626,6 +10791,7 @@ __export(exports_node_exports, {
10626
10791
  NOOP_SPAN: () => NOOP_SPAN,
10627
10792
  NOOP_SPAN_PERMALINK: () => NOOP_SPAN_PERMALINK,
10628
10793
  NoopSpan: () => NoopSpan,
10794
+ OTELIDGenerator: () => OTELIDGenerator,
10629
10795
  Project: () => Project2,
10630
10796
  ProjectNameIdMap: () => ProjectNameIdMap,
10631
10797
  Prompt: () => Prompt2,
@@ -10637,6 +10803,7 @@ __export(exports_node_exports, {
10637
10803
  SpanImpl: () => SpanImpl,
10638
10804
  TestBackgroundLogger: () => TestBackgroundLogger,
10639
10805
  ToolBuilder: () => ToolBuilder,
10806
+ UUIDGenerator: () => UUIDGenerator,
10640
10807
  X_CACHED_HEADER: () => X_CACHED_HEADER,
10641
10808
  _exportsForTestingOnly: () => _exportsForTestingOnly,
10642
10809
  _internalGetGlobalState: () => _internalGetGlobalState,
@@ -10647,10 +10814,12 @@ __export(exports_node_exports, {
10647
10814
  currentExperiment: () => currentExperiment,
10648
10815
  currentLogger: () => currentLogger,
10649
10816
  currentSpan: () => currentSpan,
10817
+ deepCopyEvent: () => deepCopyEvent,
10650
10818
  defaultErrorScoreHandler: () => defaultErrorScoreHandler,
10651
10819
  deserializePlainStringAsJSON: () => deserializePlainStringAsJSON,
10652
10820
  devNullWritableStream: () => devNullWritableStream,
10653
10821
  flush: () => flush,
10822
+ getIdGenerator: () => getIdGenerator,
10654
10823
  getPromptVersions: () => getPromptVersions,
10655
10824
  getSpanParentObject: () => getSpanParentObject,
10656
10825
  graph: () => graph_framework_exports,
@@ -10694,6 +10863,8 @@ __export(exports_node_exports, {
10694
10863
  wrapAISDK: () => wrapAISDK,
10695
10864
  wrapAISDKModel: () => wrapAISDKModel,
10696
10865
  wrapAnthropic: () => wrapAnthropic,
10866
+ wrapClaudeAgentSDK: () => wrapClaudeAgentSDK,
10867
+ wrapMastraAgent: () => wrapMastraAgent,
10697
10868
  wrapOpenAI: () => wrapOpenAI,
10698
10869
  wrapOpenAIv4: () => wrapOpenAIv4,
10699
10870
  wrapTraced: () => wrapTraced
@@ -11866,12 +12037,12 @@ var BarProgressReporter = class {
11866
12037
  };
11867
12038
 
11868
12039
  // src/eval-parameters.ts
11869
- import { z as z9 } from "zod/v3";
12040
+ import { z as z10 } from "zod/v3";
11870
12041
 
11871
12042
  // src/framework2.ts
11872
12043
  import path2 from "path";
11873
12044
  import slugifyLib from "slugify";
11874
- import { z as z8 } from "zod/v3";
12045
+ import { z as z9 } from "zod/v3";
11875
12046
  var ProjectBuilder = class {
11876
12047
  create(opts) {
11877
12048
  return new Project2(opts);
@@ -12105,23 +12276,23 @@ var CodePrompt = class {
12105
12276
  };
12106
12277
  }
12107
12278
  };
12108
- var promptContentsSchema = z8.union([
12109
- z8.object({
12110
- prompt: z8.string()
12279
+ var promptContentsSchema = z9.union([
12280
+ z9.object({
12281
+ prompt: z9.string()
12111
12282
  }),
12112
- z8.object({
12113
- messages: z8.array(ChatCompletionMessageParam)
12283
+ z9.object({
12284
+ messages: z9.array(ChatCompletionMessageParam)
12114
12285
  })
12115
12286
  ]);
12116
12287
  var promptDefinitionSchema = promptContentsSchema.and(
12117
- z8.object({
12118
- model: z8.string(),
12288
+ z9.object({
12289
+ model: z9.string(),
12119
12290
  params: ModelParams.optional()
12120
12291
  })
12121
12292
  );
12122
12293
  var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
12123
- z8.object({
12124
- tools: z8.array(ToolFunctionDefinition).optional()
12294
+ z9.object({
12295
+ tools: z9.array(ToolFunctionDefinition).optional()
12125
12296
  })
12126
12297
  );
12127
12298
  var PromptBuilder = class {
@@ -12189,7 +12360,7 @@ var ProjectNameIdMap = class {
12189
12360
  const response = await _internalGetGlobalState().appConn().post_json("api/project/register", {
12190
12361
  project_name: projectName
12191
12362
  });
12192
- const result = z8.object({
12363
+ const result = z9.object({
12193
12364
  project: Project
12194
12365
  }).parse(response);
12195
12366
  const projectId = result.project.id;
@@ -12203,7 +12374,7 @@ var ProjectNameIdMap = class {
12203
12374
  const response = await _internalGetGlobalState().appConn().post_json("api/project/get", {
12204
12375
  id: projectId
12205
12376
  });
12206
- const result = z8.array(Project).nonempty().parse(response);
12377
+ const result = z9.array(Project).nonempty().parse(response);
12207
12378
  const projectName = result[0].name;
12208
12379
  this.idToName[projectId] = projectName;
12209
12380
  this.nameToId[projectName] = projectId;
@@ -12219,15 +12390,15 @@ var ProjectNameIdMap = class {
12219
12390
  };
12220
12391
 
12221
12392
  // src/eval-parameters.ts
12222
- var evalParametersSchema = z9.record(
12223
- z9.string(),
12224
- z9.union([
12225
- z9.object({
12226
- type: z9.literal("prompt"),
12393
+ var evalParametersSchema = z10.record(
12394
+ z10.string(),
12395
+ z10.union([
12396
+ z10.object({
12397
+ type: z10.literal("prompt"),
12227
12398
  default: promptDefinitionWithToolsSchema.optional(),
12228
- description: z9.string().optional()
12399
+ description: z10.string().optional()
12229
12400
  }),
12230
- z9.instanceof(z9.ZodType)
12401
+ z10.instanceof(z10.ZodType)
12231
12402
  // For Zod schemas
12232
12403
  ])
12233
12404
  );
@@ -13208,7 +13379,7 @@ function parseSpanFromResponseCreateParams(params) {
13208
13379
  function parseEventFromResponseCreateResult(result) {
13209
13380
  const data = {};
13210
13381
  if (result?.output !== void 0) {
13211
- data.output = result.output;
13382
+ data.output = processImagesInOutput(result.output);
13212
13383
  }
13213
13384
  if (result) {
13214
13385
  const { output, usage, ...metadata } = result;
@@ -13219,6 +13390,35 @@ function parseEventFromResponseCreateResult(result) {
13219
13390
  data.metrics = parseMetricsFromUsage(result?.usage);
13220
13391
  return data;
13221
13392
  }
13393
+ function processImagesInOutput(output) {
13394
+ if (Array.isArray(output)) {
13395
+ return output.map(processImagesInOutput);
13396
+ }
13397
+ if (isObject(output)) {
13398
+ if (output.type === "image_generation_call" && output.result && typeof output.result === "string") {
13399
+ const fileExtension = output.output_format || "png";
13400
+ const contentType = `image/${fileExtension}`;
13401
+ const baseFilename = output.revised_prompt && typeof output.revised_prompt === "string" ? output.revised_prompt.slice(0, 50).replace(/[^a-zA-Z0-9]/g, "_") : "generated_image";
13402
+ const filename = `${baseFilename}.${fileExtension}`;
13403
+ const binaryString = atob(output.result);
13404
+ const bytes = new Uint8Array(binaryString.length);
13405
+ for (let i = 0; i < binaryString.length; i++) {
13406
+ bytes[i] = binaryString.charCodeAt(i);
13407
+ }
13408
+ const blob = new Blob([bytes], { type: contentType });
13409
+ const attachment = new Attachment({
13410
+ data: blob,
13411
+ filename,
13412
+ contentType
13413
+ });
13414
+ return {
13415
+ ...output,
13416
+ result: attachment
13417
+ };
13418
+ }
13419
+ }
13420
+ return output;
13421
+ }
13222
13422
  function parseSpanFromResponseParseParams(params) {
13223
13423
  const spanArgs = {
13224
13424
  name: "openai.responses.parse",
@@ -13242,7 +13442,7 @@ function parseSpanFromResponseParseParams(params) {
13242
13442
  function parseEventFromResponseParseResult(result) {
13243
13443
  const data = {};
13244
13444
  if (result?.output !== void 0) {
13245
- data.output = result.output;
13445
+ data.output = processImagesInOutput(result.output);
13246
13446
  }
13247
13447
  if (result) {
13248
13448
  const { output, usage, ...metadata } = result;
@@ -13286,7 +13486,7 @@ function parseLogFromItem(item) {
13286
13486
  case "response.completed":
13287
13487
  const data = {};
13288
13488
  if (response?.output !== void 0) {
13289
- data.output = response.output;
13489
+ data.output = processImagesInOutput(response.output);
13290
13490
  }
13291
13491
  if (response) {
13292
13492
  const { usage, output, ...metadata } = response;
@@ -13907,6 +14107,9 @@ function extractModelFromResult(result) {
13907
14107
  }
13908
14108
  return void 0;
13909
14109
  }
14110
+ function extractModelFromWrapGenerateCallback(model) {
14111
+ return model?.modelId;
14112
+ }
13910
14113
  function camelToSnake(str) {
13911
14114
  return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
13912
14115
  }
@@ -14079,7 +14282,11 @@ var V2_EXCLUDE_KEYS = /* @__PURE__ */ new Set([
14079
14282
  ]);
14080
14283
  function BraintrustMiddleware(config = {}) {
14081
14284
  return {
14082
- wrapGenerate: async ({ doGenerate, params }) => {
14285
+ wrapGenerate: async ({
14286
+ doGenerate,
14287
+ params,
14288
+ model: modelFromWrapGenerate
14289
+ }) => {
14083
14290
  const spanArgs = {
14084
14291
  name: "ai-sdk.generateText",
14085
14292
  spanAttributes: {
@@ -14106,6 +14313,13 @@ function BraintrustMiddleware(config = {}) {
14106
14313
  const model = extractModelFromResult(result);
14107
14314
  if (model !== void 0) {
14108
14315
  metadata.model = model;
14316
+ } else if (modelFromWrapGenerate) {
14317
+ const modelId = extractModelFromWrapGenerateCallback(
14318
+ modelFromWrapGenerate
14319
+ );
14320
+ if (modelId) {
14321
+ metadata.model = modelId;
14322
+ }
14109
14323
  }
14110
14324
  let toolCalls = extractToolCallsFromSteps(result?.steps);
14111
14325
  if (!toolCalls || toolCalls.length === 0) {
@@ -14755,6 +14969,146 @@ function wrapAISDK(ai) {
14755
14969
  };
14756
14970
  }
14757
14971
 
14972
+ // src/wrappers/mastra.ts
14973
+ var aiSDKFormatWarning = false;
14974
+ function wrapMastraAgent(agent, options) {
14975
+ const prefix = options?.name ?? options?.span_name ?? agent.name ?? "Agent";
14976
+ if (!hasAllMethods(agent)) {
14977
+ return agent;
14978
+ }
14979
+ if (agent.tools) {
14980
+ agent.__setTools(wrapTools(agent.tools));
14981
+ }
14982
+ return new Proxy(agent, {
14983
+ get(target, prop, receiver) {
14984
+ const value = Reflect.get(target, prop, receiver);
14985
+ if (prop === "generateVNext" && typeof value === "function") {
14986
+ return wrapGenerateVNext(value, target, prefix);
14987
+ }
14988
+ if (prop === "streamVNext" && typeof value === "function") {
14989
+ return wrapStreamVNext(value, target, prefix);
14990
+ }
14991
+ if (typeof value === "function") {
14992
+ return value.bind(target);
14993
+ }
14994
+ return value;
14995
+ }
14996
+ });
14997
+ }
14998
+ function hasAllMethods(a) {
14999
+ return typeof a.generateVNext === "function" && typeof a.streamVNext === "function";
15000
+ }
15001
+ function wrapGenerateVNext(original, target, prefix) {
15002
+ return function(...args) {
15003
+ const input = args[0];
15004
+ return traced(
15005
+ async (span) => {
15006
+ const result = await original.apply(target, args);
15007
+ const provider = detectProviderFromResult(result);
15008
+ const model = extractModelFromResult(result);
15009
+ const finishReason = normalizeFinishReason(result?.finishReason);
15010
+ const metrics = result?.usage ? normalizeUsageMetrics(
15011
+ result.usage,
15012
+ provider,
15013
+ result.providerMetadata
15014
+ ) : {};
15015
+ span.log({
15016
+ input,
15017
+ output: result,
15018
+ metadata: {
15019
+ agent_name: target.name ?? prefix,
15020
+ ...provider ? { provider } : {},
15021
+ ...model ? { model } : {},
15022
+ ...finishReason ? { finish_reason: finishReason } : {}
15023
+ },
15024
+ metrics
15025
+ });
15026
+ return result;
15027
+ },
15028
+ {
15029
+ name: `${prefix}.generateVNext`
15030
+ }
15031
+ );
15032
+ };
15033
+ }
15034
+ function wrapStreamVNext(original, target, prefix) {
15035
+ return function(...args) {
15036
+ const input = args[0];
15037
+ const span = startSpan({
15038
+ name: `${prefix}.streamVNext`,
15039
+ event: {
15040
+ input,
15041
+ metadata: {
15042
+ agent_name: target.name ?? prefix
15043
+ }
15044
+ }
15045
+ });
15046
+ const baseOpts = typeof args[1] === "object" && args[1] !== null ? args[1] : {};
15047
+ if (baseOpts.format && baseOpts.format !== "aisdk" && !aiSDKFormatWarning) {
15048
+ aiSDKFormatWarning = true;
15049
+ console.warn(
15050
+ `Braintrust Mastra wrapper: For best compatibility, use { format: 'aisdk' } (AI SDK v5) instead of format: '${baseOpts.format}'. See https://mastra.ai/en/docs/frameworks/agentic-uis/ai-sdk for more details.`
15051
+ );
15052
+ }
15053
+ const wrappedOpts = {
15054
+ ...baseOpts,
15055
+ format: baseOpts.format || "aisdk"
15056
+ // Default to AI SDK v5 format if not specified
15057
+ };
15058
+ const userOnChunk = baseOpts?.onChunk;
15059
+ const userOnFinish = baseOpts?.onFinish;
15060
+ const userOnError = baseOpts?.onError;
15061
+ const startTime = Date.now();
15062
+ let receivedFirst = false;
15063
+ wrappedOpts.onChunk = (chunk) => {
15064
+ try {
15065
+ userOnChunk?.(chunk);
15066
+ } finally {
15067
+ if (!receivedFirst) {
15068
+ receivedFirst = true;
15069
+ span.log({
15070
+ metrics: { time_to_first_token: (Date.now() - startTime) / 1e3 }
15071
+ });
15072
+ }
15073
+ }
15074
+ };
15075
+ wrappedOpts.onFinish = async (event) => {
15076
+ try {
15077
+ await userOnFinish?.(event);
15078
+ } finally {
15079
+ const e = event;
15080
+ const provider = detectProviderFromResult(e);
15081
+ const model = extractModelFromResult(e);
15082
+ const finishReason = normalizeFinishReason(e?.finishReason);
15083
+ const metrics = e?.usage ? normalizeUsageMetrics(e.usage, provider, e.providerMetadata) : {};
15084
+ span.log({
15085
+ output: e.text ?? e.content ?? e,
15086
+ metadata: {
15087
+ agent_name: target.name ?? prefix,
15088
+ ...provider ? { provider } : {},
15089
+ ...model ? { model } : {},
15090
+ ...finishReason ? { finish_reason: finishReason } : {}
15091
+ },
15092
+ metrics
15093
+ });
15094
+ span.end();
15095
+ }
15096
+ };
15097
+ wrappedOpts.onError = async (err) => {
15098
+ try {
15099
+ await userOnError?.(err);
15100
+ } finally {
15101
+ logError(span, err);
15102
+ span.end();
15103
+ }
15104
+ };
15105
+ return withCurrent(
15106
+ span,
15107
+ () => original.apply(target, [args[0], wrappedOpts, ...args.slice(2)])
15108
+ );
15109
+ };
15110
+ }
15111
+
14758
15112
  // src/wrappers/anthropic.ts
14759
15113
  function wrapAnthropic(anthropic) {
14760
15114
  const au = anthropic;
@@ -14955,7 +15309,7 @@ function streamNextProxy(stream, sspan) {
14955
15309
  };
14956
15310
  }
14957
15311
  function parseEventFromMessage(message) {
14958
- const output = message?.content || null;
15312
+ const output = message ? { role: message.role, content: message.content } : null;
14959
15313
  const metrics = parseMetricsFromUsage2(message?.usage);
14960
15314
  const metas = ["stop_reason", "stop_sequence"];
14961
15315
  const metadata = {};
@@ -14995,6 +15349,282 @@ function coalesceInput(messages, system) {
14995
15349
  return input;
14996
15350
  }
14997
15351
 
15352
+ // src/wrappers/claude-agent-sdk.ts
15353
+ function filterSerializableOptions(options) {
15354
+ const allowedKeys = [
15355
+ "model",
15356
+ "maxTurns",
15357
+ "cwd",
15358
+ "continue",
15359
+ "allowedTools",
15360
+ "disallowedTools",
15361
+ "additionalDirectories",
15362
+ "permissionMode",
15363
+ "debug",
15364
+ "apiKey",
15365
+ "apiKeySource",
15366
+ "agentName",
15367
+ "instructions"
15368
+ ];
15369
+ const filtered = {};
15370
+ for (const key of allowedKeys) {
15371
+ if (options[key] !== void 0) {
15372
+ filtered[key] = options[key];
15373
+ }
15374
+ }
15375
+ return filtered;
15376
+ }
15377
+ function wrapClaudeAgentQuery(queryFn, defaultThis) {
15378
+ const proxy = new Proxy(queryFn, {
15379
+ apply(target, thisArg, argArray) {
15380
+ const params = argArray[0] ?? {};
15381
+ const { prompt, options = {} } = params;
15382
+ const span = startSpan({
15383
+ name: "Claude Agent",
15384
+ spanAttributes: {
15385
+ type: "task" /* TASK */
15386
+ },
15387
+ event: {
15388
+ input: typeof prompt === "string" ? prompt : { type: "streaming", description: "AsyncIterable<SDKMessage>" },
15389
+ metadata: filterSerializableOptions(options)
15390
+ }
15391
+ });
15392
+ const finalResults = [];
15393
+ let finalUsageMetrics;
15394
+ let accumulatedOutputTokens = 0;
15395
+ let currentMessageId;
15396
+ let currentMessageStartTime = getCurrentUnixTimestamp();
15397
+ const currentMessages = [];
15398
+ const createLLMSpan = async () => {
15399
+ const finalMessageContent = await _createLLMSpanForMessages(
15400
+ currentMessages,
15401
+ prompt,
15402
+ finalResults,
15403
+ options,
15404
+ currentMessageStartTime,
15405
+ await span.export()
15406
+ );
15407
+ if (finalMessageContent) {
15408
+ finalResults.push(finalMessageContent);
15409
+ }
15410
+ const lastMessage = currentMessages[currentMessages.length - 1];
15411
+ if (lastMessage?.message?.usage) {
15412
+ const outputTokens = getNumberProperty(lastMessage.message.usage, "output_tokens") || 0;
15413
+ accumulatedOutputTokens += outputTokens;
15414
+ }
15415
+ currentMessages.length = 0;
15416
+ };
15417
+ const wrappedGenerator = async function* () {
15418
+ try {
15419
+ const invocationTarget = thisArg === proxy || thisArg === void 0 ? defaultThis ?? thisArg : thisArg;
15420
+ const generator = withCurrent(
15421
+ span,
15422
+ () => Reflect.apply(target, invocationTarget, argArray)
15423
+ );
15424
+ for await (const message of generator) {
15425
+ const currentTime = getCurrentUnixTimestamp();
15426
+ const messageId = message.message?.id;
15427
+ if (messageId && messageId !== currentMessageId) {
15428
+ await createLLMSpan();
15429
+ currentMessageId = messageId;
15430
+ currentMessageStartTime = currentTime;
15431
+ }
15432
+ if (message.type === "assistant" && message.message?.usage) {
15433
+ currentMessages.push(message);
15434
+ }
15435
+ if (message.type === "result" && message.usage) {
15436
+ finalUsageMetrics = _extractUsageFromMessage(message);
15437
+ if (currentMessages.length > 0 && finalUsageMetrics.completion_tokens !== void 0) {
15438
+ const lastMessage = currentMessages[currentMessages.length - 1];
15439
+ if (lastMessage?.message?.usage) {
15440
+ const adjustedTokens = finalUsageMetrics.completion_tokens - accumulatedOutputTokens;
15441
+ if (adjustedTokens >= 0) {
15442
+ lastMessage.message.usage.output_tokens = adjustedTokens;
15443
+ }
15444
+ }
15445
+ }
15446
+ const result_metadata = {};
15447
+ if (message.num_turns !== void 0) {
15448
+ result_metadata.num_turns = message.num_turns;
15449
+ }
15450
+ if (message.session_id !== void 0) {
15451
+ result_metadata.session_id = message.session_id;
15452
+ }
15453
+ if (Object.keys(result_metadata).length > 0) {
15454
+ span.log({
15455
+ metadata: result_metadata
15456
+ });
15457
+ }
15458
+ }
15459
+ yield message;
15460
+ }
15461
+ await createLLMSpan();
15462
+ span.log({
15463
+ output: finalResults.length > 0 ? finalResults[finalResults.length - 1] : void 0
15464
+ });
15465
+ } catch (error2) {
15466
+ span.log({
15467
+ error: error2 instanceof Error ? error2.message : String(error2)
15468
+ });
15469
+ throw error2;
15470
+ } finally {
15471
+ span.end();
15472
+ }
15473
+ }();
15474
+ return wrappedGenerator;
15475
+ }
15476
+ });
15477
+ return proxy;
15478
+ }
15479
+ function wrapClaudeAgentTool(toolDef) {
15480
+ const originalHandler = toolDef.handler;
15481
+ const wrappedHandler = (args, extra) => traced(
15482
+ async (span) => {
15483
+ span.log({
15484
+ input: args,
15485
+ metadata: {
15486
+ tool_name: toolDef.name,
15487
+ tool_description: toolDef.description
15488
+ }
15489
+ });
15490
+ const result = await originalHandler(args, extra);
15491
+ span.log({
15492
+ output: result
15493
+ });
15494
+ return result;
15495
+ },
15496
+ {
15497
+ name: `${toolDef.name}`,
15498
+ spanAttributes: {
15499
+ type: "tool" /* TOOL */
15500
+ }
15501
+ }
15502
+ );
15503
+ return {
15504
+ ...toolDef,
15505
+ handler: wrappedHandler
15506
+ };
15507
+ }
15508
+ function _buildLLMInput(prompt, conversationHistory) {
15509
+ const promptMessage = typeof prompt === "string" ? { content: prompt, role: "user" } : void 0;
15510
+ const inputParts = [
15511
+ ...promptMessage ? [promptMessage] : [],
15512
+ ...conversationHistory
15513
+ ];
15514
+ return inputParts.length > 0 ? inputParts : void 0;
15515
+ }
15516
+ function _extractUsageFromMessage(message) {
15517
+ const metrics = {};
15518
+ let usage;
15519
+ if (message.type === "assistant") {
15520
+ usage = message.message?.usage;
15521
+ } else if (message.type === "result") {
15522
+ usage = message.usage;
15523
+ }
15524
+ if (!usage || typeof usage !== "object") {
15525
+ return metrics;
15526
+ }
15527
+ const inputTokens = getNumberProperty(usage, "input_tokens");
15528
+ if (inputTokens !== void 0) {
15529
+ metrics.prompt_tokens = inputTokens;
15530
+ }
15531
+ const outputTokens = getNumberProperty(usage, "output_tokens");
15532
+ if (outputTokens !== void 0) {
15533
+ metrics.completion_tokens = outputTokens;
15534
+ }
15535
+ const cacheReadTokens = getNumberProperty(usage, "cache_read_input_tokens") || 0;
15536
+ const cacheCreationTokens = getNumberProperty(usage, "cache_creation_input_tokens") || 0;
15537
+ if (cacheReadTokens > 0 || cacheCreationTokens > 0) {
15538
+ const cacheTokens = extractAnthropicCacheTokens(
15539
+ cacheReadTokens,
15540
+ cacheCreationTokens
15541
+ );
15542
+ Object.assign(metrics, cacheTokens);
15543
+ }
15544
+ if (Object.keys(metrics).length > 0) {
15545
+ Object.assign(metrics, finalizeAnthropicTokens(metrics));
15546
+ }
15547
+ return metrics;
15548
+ }
15549
+ async function _createLLMSpanForMessages(messages, prompt, conversationHistory, options, startTime, parentSpan) {
15550
+ if (messages.length === 0) return void 0;
15551
+ const lastMessage = messages[messages.length - 1];
15552
+ if (lastMessage.type !== "assistant" || !lastMessage.message?.usage) {
15553
+ return void 0;
15554
+ }
15555
+ const model = lastMessage.message.model || options.model;
15556
+ const usage = _extractUsageFromMessage(lastMessage);
15557
+ const input = _buildLLMInput(prompt, conversationHistory);
15558
+ const outputs = messages.map(
15559
+ (m) => m.message?.content && m.message?.role ? { content: m.message.content, role: m.message.role } : void 0
15560
+ ).filter((c) => c !== void 0);
15561
+ await traced(
15562
+ (llmSpan) => {
15563
+ llmSpan.log({
15564
+ input,
15565
+ output: outputs,
15566
+ metadata: model ? { model } : void 0,
15567
+ metrics: usage
15568
+ });
15569
+ },
15570
+ {
15571
+ name: "anthropic.messages.create",
15572
+ spanAttributes: {
15573
+ type: "llm" /* LLM */
15574
+ },
15575
+ startTime,
15576
+ parent: parentSpan
15577
+ }
15578
+ );
15579
+ return lastMessage.message?.content && lastMessage.message?.role ? { content: lastMessage.message.content, role: lastMessage.message.role } : void 0;
15580
+ }
15581
+ function wrapClaudeAgentSDK(sdk) {
15582
+ const cache = /* @__PURE__ */ new Map();
15583
+ return new Proxy(sdk, {
15584
+ get(target, prop, receiver) {
15585
+ if (cache.has(prop)) {
15586
+ return cache.get(prop);
15587
+ }
15588
+ const value = Reflect.get(target, prop, receiver);
15589
+ if (prop === "query" && typeof value === "function") {
15590
+ const wrappedQuery = wrapClaudeAgentQuery(
15591
+ value,
15592
+ target
15593
+ );
15594
+ cache.set(prop, wrappedQuery);
15595
+ return wrappedQuery;
15596
+ }
15597
+ if (prop === "tool" && typeof value === "function") {
15598
+ const toolFn = value;
15599
+ const wrappedToolFactory = new Proxy(toolFn, {
15600
+ apply(toolTarget, thisArg, argArray) {
15601
+ const invocationTarget = thisArg === receiver || thisArg === void 0 ? target : thisArg;
15602
+ const toolDef = Reflect.apply(
15603
+ toolTarget,
15604
+ invocationTarget,
15605
+ argArray
15606
+ );
15607
+ if (toolDef && typeof toolDef === "object" && "handler" in toolDef) {
15608
+ return wrapClaudeAgentTool(
15609
+ toolDef
15610
+ );
15611
+ }
15612
+ return toolDef;
15613
+ }
15614
+ });
15615
+ cache.set(prop, wrappedToolFactory);
15616
+ return wrappedToolFactory;
15617
+ }
15618
+ if (typeof value === "function") {
15619
+ const bound = value.bind(target);
15620
+ cache.set(prop, bound);
15621
+ return bound;
15622
+ }
15623
+ return value;
15624
+ }
15625
+ });
15626
+ }
15627
+
14998
15628
  // src/otel.ts
14999
15629
  var otelApi = null;
15000
15630
  var otelSdk = null;
@@ -15256,44 +15886,44 @@ var BraintrustExporter = class _BraintrustExporter {
15256
15886
  };
15257
15887
 
15258
15888
  // dev/types.ts
15259
- import { z as z10 } from "zod/v3";
15260
- var evalBodySchema = z10.object({
15261
- name: z10.string(),
15262
- parameters: z10.record(z10.string(), z10.unknown()).nullish(),
15889
+ import { z as z11 } from "zod/v3";
15890
+ var evalBodySchema = z11.object({
15891
+ name: z11.string(),
15892
+ parameters: z11.record(z11.string(), z11.unknown()).nullish(),
15263
15893
  data: RunEval.shape.data,
15264
- scores: z10.array(
15265
- z10.object({
15894
+ scores: z11.array(
15895
+ z11.object({
15266
15896
  function_id: FunctionId,
15267
- name: z10.string()
15897
+ name: z11.string()
15268
15898
  })
15269
15899
  ).nullish(),
15270
- experiment_name: z10.string().nullish(),
15271
- project_id: z10.string().nullish(),
15900
+ experiment_name: z11.string().nullish(),
15901
+ project_id: z11.string().nullish(),
15272
15902
  parent: InvokeParent.optional(),
15273
- stream: z10.boolean().optional()
15903
+ stream: z11.boolean().optional()
15274
15904
  });
15275
- var evalParametersSerializedSchema = z10.record(
15276
- z10.string(),
15277
- z10.union([
15278
- z10.object({
15279
- type: z10.literal("prompt"),
15905
+ var evalParametersSerializedSchema = z11.record(
15906
+ z11.string(),
15907
+ z11.union([
15908
+ z11.object({
15909
+ type: z11.literal("prompt"),
15280
15910
  default: PromptData.optional(),
15281
- description: z10.string().optional()
15911
+ description: z11.string().optional()
15282
15912
  }),
15283
- z10.object({
15284
- type: z10.literal("data"),
15285
- schema: z10.record(z10.unknown()),
15913
+ z11.object({
15914
+ type: z11.literal("data"),
15915
+ schema: z11.record(z11.unknown()),
15286
15916
  // JSON Schema
15287
- default: z10.unknown().optional(),
15288
- description: z10.string().optional()
15917
+ default: z11.unknown().optional(),
15918
+ description: z11.string().optional()
15289
15919
  })
15290
15920
  ])
15291
15921
  );
15292
- var evaluatorDefinitionSchema = z10.object({
15922
+ var evaluatorDefinitionSchema = z11.object({
15293
15923
  parameters: evalParametersSerializedSchema.optional()
15294
15924
  });
15295
- var evaluatorDefinitionsSchema = z10.record(
15296
- z10.string(),
15925
+ var evaluatorDefinitionsSchema = z11.record(
15926
+ z11.string(),
15297
15927
  evaluatorDefinitionSchema
15298
15928
  );
15299
15929
 
@@ -15319,6 +15949,7 @@ export {
15319
15949
  Experiment2 as Experiment,
15320
15950
  ExternalAttachment,
15321
15951
  FailedHTTPResponse,
15952
+ IDGenerator,
15322
15953
  INTERNAL_BTQL_LIMIT,
15323
15954
  LEGACY_CACHED_HEADER,
15324
15955
  LazyValue,
@@ -15326,6 +15957,7 @@ export {
15326
15957
  NOOP_SPAN,
15327
15958
  NOOP_SPAN_PERMALINK,
15328
15959
  NoopSpan,
15960
+ OTELIDGenerator,
15329
15961
  Project2 as Project,
15330
15962
  ProjectNameIdMap,
15331
15963
  Prompt2 as Prompt,
@@ -15337,6 +15969,7 @@ export {
15337
15969
  SpanImpl,
15338
15970
  TestBackgroundLogger,
15339
15971
  ToolBuilder,
15972
+ UUIDGenerator,
15340
15973
  X_CACHED_HEADER,
15341
15974
  _exportsForTestingOnly,
15342
15975
  _internalGetGlobalState,
@@ -15347,6 +15980,7 @@ export {
15347
15980
  currentExperiment,
15348
15981
  currentLogger,
15349
15982
  currentSpan,
15983
+ deepCopyEvent,
15350
15984
  index_default as default,
15351
15985
  defaultErrorScoreHandler,
15352
15986
  deserializePlainStringAsJSON,
@@ -15354,6 +15988,7 @@ export {
15354
15988
  evaluatorDefinitionSchema,
15355
15989
  evaluatorDefinitionsSchema,
15356
15990
  flush,
15991
+ getIdGenerator,
15357
15992
  getPromptVersions,
15358
15993
  getSpanParentObject,
15359
15994
  graph_framework_exports as graph,
@@ -15397,6 +16032,8 @@ export {
15397
16032
  wrapAISDK,
15398
16033
  wrapAISDKModel,
15399
16034
  wrapAnthropic,
16035
+ wrapClaudeAgentSDK,
16036
+ wrapMastraAgent,
15400
16037
  wrapOpenAI,
15401
16038
  wrapOpenAIv4,
15402
16039
  wrapTraced